コード例 #1
0
ファイル: main.go プロジェクト: bmbernie/socks
func init() {
	flag.BoolVarP(&flagVerbose, "verbose", "v", false, "be more verbose")
	flag.BoolVarP(&flagQuiet, "quiet", "q", false, "be quiet")
	flag.BoolVarP(&flagTrace, "trace", "t", false, "trace bytes copied")

	flag.StringVarP(&flagHost, "host", "h", "", "host to listen on")
	flag.Uint16VarP(&flagPort, "port", "p", 8000, "port to listen on")
	flag.VarP(&flagAllowedSourceIPs, "source-ips", "s",
		"valid source IP addresses (if none given, all allowed)")
	flag.VarP(&flagAllowedDestinationIPs, "dest-ips", "d",
		"valid destination IP addresses (if none given, all allowed)")

	flag.StringVar(&flagRemoteListener, "remote-listener", "",
		"open the SOCKS port on the remote address (e.g. ssh://user:pass@host:port)")
}
コード例 #2
0
ファイル: drive.go プロジェクト: shimondoodkin/rclone
// Register with Fs
func init() {
	fs.Register(&fs.FsInfo{
		Name:  "drive",
		NewFs: NewFs,
		Config: func(name string) {
			driveAuth.Config(name)
		},
		Options: []fs.Option{{
			Name: "client_id",
			Help: "Google Application Client Id - leave blank to use rclone's.",
		}, {
			Name: "client_secret",
			Help: "Google Application Client Secret - leave blank to use rclone's.",
		}},
	})
	pflag.VarP(&driveUploadCutoff, "drive-upload-cutoff", "", "Cutoff for switching to chunked upload")
	pflag.VarP(&chunkSize, "drive-chunk-size", "", "Upload chunk size. Must a power of 2 >= 256k.")
}
コード例 #3
0
ファイル: main.go プロジェクト: pyting/jsonpath-1
func main() {
	var pathStrings pathSlice
	filePtr := flag.StringP("file", "f", "", "Path to json file")
	jsonPtr := flag.StringP("json", "j", "", "JSON text")
	flag.VarP(&pathStrings, "path", "p", "One or more paths to target in JSON")
	showKeysPtr := flag.BoolP("keys", "k", false, "Print keys & indexes that lead to value")
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
		flag.PrintDefaults()
		fmt.Fprintln(os.Stderr, "Pipe JSON to StdIn by not specifying --file or --json ")
	}
	flag.Parse()

	if len(pathStrings) == 0 {
		fmt.Println("Must specify one or more paths with the --path flag")
		os.Exit(1)
	}

	paths, err := jsonpath.ParsePaths(pathStrings...)
	if err != nil {
		fmt.Println(fmt.Errorf("Failed to parse paths: %q", err.Error()))
		os.Exit(1)
	}

	if filePtr != nil && *filePtr != "" {
		f, err := os.Open(*filePtr)
		if err != nil {
			fmt.Println(fmt.Errorf("Failed to open file: %q", err.Error()))
			os.Exit(1)
		}

		eval, err := jsonpath.EvalPathsInReader(f, paths)
		checkAndHandleError(err)
		run(eval, *showKeysPtr)
		checkAndHandleError(eval.Error)
		f.Close()

	} else if jsonPtr != nil && *jsonPtr != "" {
		eval, err := jsonpath.EvalPathsInBytes([]byte(*jsonPtr), paths)
		checkAndHandleError(err)
		run(eval, *showKeysPtr)
		checkAndHandleError(eval.Error)
	} else {
		reader := bufio.NewReader(os.Stdin)
		eval, err := jsonpath.EvalPathsInReader(reader, paths)
		checkAndHandleError(err)
		run(eval, *showKeysPtr)
		checkAndHandleError(eval.Error)
	}
}
コード例 #4
0
ファイル: main.go プロジェクト: jonasi/project
func main() {
	var (
		// general options
		stateDir = pflag.String("statedir", "", "the server state directory")
		help     = pflag.BoolP("help", "h", false, "show this help")

		// server options
		server = pflag.BoolP("server", "s", false, "run the server in the foreground")
		port   = pflag.IntP("port", "p", 40000, "server port to listen on")

		// client options
		method  = pflag.StringP("method", "X", "GET", "client method")
		plugin  = pflag.String("plugin", "", "client plugin")
		data    = pflag.StringP("data", "d", "", "client body")
		headers = &repString{[]string{}}
		verbose = pflag.BoolP("verbose", "v", false, "show full http response")
	)

	pflag.VarP(headers, "header", "H", "client request header")

	pflag.Parse()

	if *help {
		os.Exit(runHelp())
	}

	if *server {
		os.Exit(runServer(*port, *stateDir))
	}

	if pflag.NArg() < 1 {
		fmt.Fprintln(os.Stderr, "must pass in path to make api call")
		runHelp()
		os.Exit(1)
	}

	os.Exit(runClient(*stateDir, *plugin, *method, pflag.Arg(0), *data, headers.strs, *verbose))
}
コード例 #5
0
ファイル: main.go プロジェクト: mclarkson/nrcq
func init() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "nrcq(8)             System Administration Utilities            nrcq(8)\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "NAME\n")
		fmt.Fprintf(os.Stderr, "  nrcq - NagRestConf Query utility\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "SYNOPSIS\n")
		fmt.Fprintf(os.Stderr, "  nrcq [options] URL ENDPOINT\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "DESCRIPTION\n")
		flag.PrintDefaults()
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "EXAMPLES\n")
		fmt.Fprintf(os.Stderr, "  Show all valid endpoints:\n")
		fmt.Fprintf(os.Stderr, "    nrcq -L\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "  List all nagios options for the servicesets table:\n")
		fmt.Fprintf(os.Stderr, "    nrcq -l servicesets\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "  Show all hosts:\n")
		fmt.Fprintf(os.Stderr, "    nrcq http://server/rest show/hosts\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "  Show a subset of hosts using a simple RE2 regular expression:\n")
		fmt.Fprintf(os.Stderr, "    nrcq http://server/rest show/hosts")
		fmt.Fprintf(os.Stderr, " -f \"name:host2\"\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "  Show a subset of services using a complex RE2 regular expression:\n")
		fmt.Fprintf(os.Stderr, "  (See https://github.com/google/re2/wiki/Syntax)\n")
		fmt.Fprintf(os.Stderr, "    nrcq http://server/rest show/services")
		fmt.Fprintf(os.Stderr, " -f \"name:\\bhost2\\b|web,svcdesc:(?i)swap\"\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "  Add a new host:\n")
		fmt.Fprintf(os.Stderr, "    nrcq http://server/rest add/hosts \\\n")
		fmt.Fprintf(os.Stderr, "      -d name:server1 \\\n")
		fmt.Fprintf(os.Stderr, "      -d alias:server1 \\\n")
		fmt.Fprintf(os.Stderr, "      -d ipaddress:server1.there.gq \\\n")
		fmt.Fprintf(os.Stderr, "      -d template:hsttmpl-local \\\n")
		fmt.Fprintf(os.Stderr, "      -d servicesets:example-lin\n")
		fmt.Fprintf(os.Stderr, "\n")
		fmt.Fprintf(os.Stderr, "  Delete a host and all of its services:\n")
		fmt.Fprintf(os.Stderr, "    nrcq http://server/rest delete/services \\\n")
		fmt.Fprintf(os.Stderr, "      -d name:server1 \\\n")
		fmt.Fprintf(os.Stderr, "      -d \"svcdesc:.*\"\n")
		fmt.Fprintf(os.Stderr, "    nrcq http://server/rest delete/hosts \\\n")
		fmt.Fprintf(os.Stderr, "      -d name:server1 \\\n")
		fmt.Fprintf(os.Stderr, "\n")
	}

	flag.StringVarP(&Args.folder, "folder", "F", "local",
		"The system folder to query.")
	flag.StringVarP(&Args.filter, "filter", "f", "",
		"A client side RE2 regex filter, 'option:regex[,option:regex]...'")
	flag.BoolVarP(&Args.version, "version", "v", false,
		"Show the version of this program.")
	flag.BoolVarP(&Args.newline, "pack", "p", false,
		"Remove spaces and lines from the Json output.")
	flag.BoolVarP(&Args.brief, "complete", "c", false,
		"Also show fields with empty values.")
	// Done automatically now:
	//flag.BoolVarP(&Args.encode, "encode", "e", false,
	//	"URL Encode output where necessary so it can be piped to another tool.")
	flag.BoolVarP(&Args.listendpoints, "listendpoints", "L", false,
		"List all endpoints/tables.")
	flag.StringVarP(&Args.username, "username", "U", "",
		"Username for Basic Auth.")
	flag.StringVarP(&Args.password, "password", "P", "",
		"Password for Basic Auth.")
	flag.StringVarP(&Args.list, "list", "l", "",
		"List all options for the specified table. Required fields are\n\t preceded by a star, '*'.")
	flag.BoolVarP(&Args.json, "json", "j", false,
		"Output in JSON format.")
	flag.VarP(&dataFlag, "data", "d",
		"Set extra data to send, 'option:value'.\n\tThe user should not urlencode data, nrcq will do it.\n\tMay be used multiple times.")
}
コード例 #6
0
ファイル: main.go プロジェクト: habajca/simple-log-search
func init() {
	(&geo).Set(defaultGeoPointString)
	flag.VarP(&geo, "geo", "g", "The origin of the search in the geo dimensions as a latitude, longitude tuple.")
}
コード例 #7
0
ファイル: pastecat.go プロジェクト: go-denji/pastecat
func init() {
	pflag.VarP(&maxSize, "max-size", "s", "Maximum size of pastes")
	pflag.VarP(&maxStorage, "max-storage", "M", "Maximum storage size to use at once")
}