• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang goopt.Flag函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/droundy/goopt.Flag函数的典型用法代码示例。如果您正苦于以下问题:Golang Flag函数的具体用法?Golang Flag怎么用?Golang Flag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Flag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: cliSetup

func cliSetup() *cliOptions {

	options := newCliOptions()

	var httpVerb = goopt.StringWithLabel([]string{"-X", "--command"}, options.httpVerb,
		"COMMAND", fmt.Sprintf("HTTP verb for request: %s", HttpVerbs))
	var httpHeaders = goopt.Strings([]string{"-H", "--header"},
		"KEY:VALUE", "Custom HTTP Headers to be sent with request (can pass multiple times)")
	var postData = goopt.StringWithLabel([]string{"-d", "--data"}, options.postData,
		"DATA", "HTTP Data for POST")
	var timeOut = goopt.IntWithLabel([]string{"-t", "--timeout"}, options.timeout,
		"TIMEOUT", "Timeout in seconds for request")
	var shouldRedirect = goopt.Flag([]string{"-r", "--redirect"}, []string{}, "Follow redirects", "")
	var isVerbose = goopt.Flag([]string{"-v", "--verbose"}, []string{}, "Verbose output", "")
	var hasColor = goopt.Flag([]string{"-c", "--color"}, []string{}, "Colored output", "")
	var isInsecureSSL = goopt.Flag([]string{"-k", "--insecure"}, []string{}, "Allow insecure https connections", "")

	goopt.Summary = "Golang based http client program"
	goopt.Parse(nil)

	options.httpVerb = *httpVerb
	options.httpHeaders = *httpHeaders
	options.postData = *postData
	options.timeout = *timeOut
	options.verbose = *isVerbose
	options.redirect = *shouldRedirect
	options.color = *hasColor
	options.sslInsecure = *isInsecureSSL
	options.arguments = goopt.Args

	exitWithMessageIfNonZero(validateOptions(options))
	exitWithMessageIfNonZero(validateArguments(options))

	return options
}
开发者ID:jshort,项目名称:gocurl,代码行数:35,代码来源:main.go


示例2: main

func main() {
	var no_cog = goopt.Flag([]string{"-C", "--no-cog"}, []string{"-c", "--cog"},
		"skip opening in cog", "open in cog")
	var no_delete = goopt.Flag([]string{"-D", "--no-delete"}, []string{"-d", "--delete"},
		"skip deleting original zip", "delete original zip")
	goopt.Parse(nil)

	boomkat(goopt.Args[0], *no_cog, *no_delete)

}
开发者ID:JonnieCache,项目名称:boomkat,代码行数:10,代码来源:boomkat.go


示例3: main

func main() {
	goopt.Author = "William Pearson"
	goopt.Version = "Rmdir"
	goopt.Summary = "Remove each DIRECTORY if it is empty"
	goopt.Usage = func() string {
		return fmt.Sprintf("Usage:\t%s [OPTION]... DIRECTORY...\n", os.Args[0]) + goopt.Summary + "\n\n" + goopt.Help()
	}
	goopt.Description = func() string {
		return goopt.Summary + "\n\nUnless --help or --version is passed."
	}
	ignorefail := goopt.Flag([]string{"--ignore-fail-on-non-empty"}, nil,
		"Ignore each failure that is from a directory not being empty", "")
	parents := goopt.Flag([]string{"-p", "--parents"}, nil, "Remove DIRECTORY and ancestors if ancestors become empty", "")
	verbose := goopt.Flag([]string{"-v", "--verbose"}, nil, "Output each directory as it is processed", "")
	goopt.NoArg([]string{"--version"}, "outputs version information and exits", coreutils.Version)
	goopt.Parse(nil)
	if len(goopt.Args) == 0 {
		coreutils.PrintUsage()
	}
	for i := range goopt.Args {
		filelisting, err := ioutil.ReadDir(goopt.Args[i])
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to remove %s: %v\n", os.Args[i+1], err)
			defer os.Exit(1)
			continue
		}
		if !*ignorefail && len(filelisting) > 0 {
			fmt.Fprintf(os.Stderr, "Failed to remove '%s' directory is non-empty\n", goopt.Args[i])
			defer os.Exit(1)
			continue
		}
		if *verbose {
			fmt.Printf("Removing directory %s\n", goopt.Args[i])
		}
		err = os.Remove(goopt.Args[i])
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to remove %s: %v\n", goopt.Args[i], err)
			defer os.Exit(1)
			continue
		}
		if !*parents {
			continue
		}
		dir := goopt.Args[i]
		if dir[len(dir)-1] == '/' {
			dir = filepath.Dir(dir)
		}
		if removeEmptyParents(dir, *verbose, *ignorefail) {
			defer os.Exit(1)
		}
	}
	return
}
开发者ID:uiri,项目名称:coreutils,代码行数:53,代码来源:main.go


示例4: init

func init() {
	format = goopt.String([]string{"--fmt", "--format"}, "",
		"Log format (e.g. '$remote_addr [$time_local] \"$request\"')")
	nginxConfig = goopt.String([]string{"--nginx"}, "",
		"Nginx config to look for 'log_format' directive. You also should specify --nginx-format")
	nginxFormat = goopt.String([]string{"--nginx-format"}, "",
		"Name of nginx 'log_format', should be passed with --nginx option")
	aggField = goopt.String([]string{"-a", "--aggregate"}, "request_time",
		"Nginx access log variable to aggregate")
	groupBy = goopt.String([]string{"-g", "--group-by"}, "request",
		"Nginx access log variable to group by")
	groupByRegexp = goopt.String([]string{"-r", "--regexp"}, "",
		"You can specify regular expression to extract exact data from group by data. "+
			"For example, you might want to group by a path inside $request, so you should "+
			"set this option to '^\\S+\\s(.*)(?:\\?.*)?$'.")
	groupByGeneralize = goopt.String([]string{"--generalize"}, "",
		"Regular expression to generalize data. For example to make /foo/123 and /foo/234 equal")
	debug = goopt.Flag([]string{"--debug"}, []string{"--no-debug"},
		"Log debug information", "Do not log debug information")
	jsonOutput = goopt.String([]string{"-o", "--json"}, "",
		"Save result as json encoded file")
}
开发者ID:satyrius,项目名称:log-parser,代码行数:22,代码来源:parser.go


示例5: main

func main() {
	var progname = os.Args[0][strings.LastIndex(os.Args[0], "/")+1:]

	var algorithm = goopt.StringWithLabel([]string{"-a", "--algorithm"}, algorithms[0],
		"ALG", fmt.Sprintf("Hashing algorithm: %s", algorithms))
	var version = goopt.Flag([]string{"-V", "--version"}, []string{}, "Display version", "")

	goopt.Summary = fmt.Sprintf("%s [OPTIONS] FILENAME\n\nMessage digest calculator with various hashing algorithms.\n\nArguments:\n  FILENAME                 File(s) to hash\n", progname)
	goopt.Parse(nil)

	var files []string = goopt.Args

	if *version {
		fmt.Printf("%s version %s\n", progname, Version)
		os.Exit(0)
	}

	validateAlgorithm(goopt.Usage(), *algorithm)
	valildateFiles(goopt.Usage(), files)

	calculateDigest(files, *algorithm)

	os.Exit(0)
}
开发者ID:jshort,项目名称:go-hash,代码行数:24,代码来源:main.go


示例6: init

func init() {
	goopt.Description = func() string {
		return "conchk v" + goopt.Version
	}
	goopt.Author = "Bruce Fitzsimons <[email protected]>"
	goopt.Version = "0.3"
	goopt.Summary = "conchk is an IP connectivity test tool designed to validate that all configured IP connectivity actually works\n " +
		"It reads a list of tests and executes them, in a parallel manner, based on the contents of each line" +
		"conchk supports tcp and udp based tests (IPv4 and IPv6), at this time.\n\n" +
		"==Notes==\n" +
		"* The incuded Excel sheet is a useful way to create and maintain the tests\n" +
		"* testing a range of supports is supported. In this case the rules for a successful test are somewhat different\n" +
		"** If one of the ports gets a successful connect, and the rest are refused (connection refused) as nothing is listening\n" +
		"\tthen this is considered to be a successful test of the range. This is the most common scenario in our experience;\n" +
		"\tthe firewalls and routing are demonstrably working, and at least one destination service is ok. If you need all ports to work\n" +
		"\tthen consider using individual tests\n" +
		"* If all tests for this host pass, then conchk will exit(0). Otherwise it will exit(1)\n" +
		"* conchk will use the current hostname, or the commandline parameter, to find the tests approprate to execute - matches on field 3.\n" +
		"\tThis means all the tests for a system, or project can be placed in one file\n" +
		"* The .csv output option will write a file much like the input file, but with two additional columns and without any comments\n" +
		"\t This file can be fed back into conchk without error.\n\n" +
		"See http://bwooce.github.io/conchk/ for more information.\n\n(c)2013 Bruce Fitzsimons.\n\n"

	Hostname, _ := os.Hostname()

	params.Debug = goopt.Flag([]string{"-d", "--debug"}, []string{}, "additional debugging output", "")
	params.TestsFile = goopt.String([]string{"-T", "--tests"}, "./tests.conchk", "test file to load")
	params.OutputFile = goopt.String([]string{"-O", "--outputcsv"}, "", "name of results .csv file to write to. A pre-existing file will be overwritten.")
	params.MyHost = goopt.String([]string{"-H", "--host"}, Hostname, "Hostname to use for config lookup")
	params.MaxStreams = goopt.Int([]string{"--maxstreams"}, 8, "Maximum simultaneous checks")
	params.Timeout = goopt.String([]string{"--timeout"}, "5s", "TCP connectivity timeout, UDP delay for ICMP responses")

	semStreams = make(semaphore, *params.MaxStreams)
	runtime.GOMAXPROCS(runtime.NumCPU())

}
开发者ID:Bwooce,项目名称:conchk,代码行数:36,代码来源:conchk.go


示例7:

	"encoding/json"
	"fmt"
	goopt "github.com/droundy/goopt"
	"net/http"
	"path/filepath"
	"strings"
)

var Version = "0.1"

var Summary = `gostatic path/to/config

Build a site.
`

var showVersion = goopt.Flag([]string{"-V", "--version"}, []string{},
	"show version and exit", "")
var showProcessors = goopt.Flag([]string{"--processors"}, []string{},
	"show internal processors", "")
var showSummary = goopt.Flag([]string{"--summary"}, []string{},
	"print everything on stdout", "")
var showConfig = goopt.Flag([]string{"--show-config"}, []string{},
	"dump config as JSON on stdout", "")
var doWatch = goopt.Flag([]string{"-w", "--watch"}, []string{},
	"watch for changes and serve them as http", "")
var port = goopt.String([]string{"-p", "--port"}, "8000",
	"port to serve on")
var verbose = goopt.Flag([]string{"-v", "--verbose"}, []string{},
	"enable verbose output", "")

// used in Page.Changed()
var force = goopt.Flag([]string{"-f", "--force"}, []string{},
开发者ID:minhajuddin,项目名称:gostatic,代码行数:32,代码来源:gostatic.go


示例8: main

	"metrics.txt",
	"the name of the file that contains the list of metric names")
var maxMetrics = goopt.Int([]string{"-x", "--maxmetrics"},
	5000,
	"the maximum number of metric names that will be used. if the number exceeds the number of names in the metric file the max in the file will be used")
var target = goopt.Alternatives(
	[]string{"-t", "--target"},
	[]string{TARGET_MONGO, TARGET_ZMQ, TARGET_TSDB},
	"sets the destination of metrics generated, default is mongo")
var sendMode = goopt.Alternatives(
	[]string{"-m", "--sendmode"},
	[]string{MODE_CONNECT, MODE_BIND},
	"mode used when sending requests over ZeroMQ, default is connect")
var doBatching = goopt.Flag(
	[]string{"--batch"},
	[]string{"--nobatch"},
	"inserts into the database will be batched",
	"inserts into the database will not be batched")
var batchSize = goopt.Int(
	[]string{"-z", "--size", "--batchsize"},
	1000,
	"sets the size of batches when inserting into the database")

// Connects to a mongo database and sends a continuous stream of metric updates
// (inserts) to the server for a specified amount of time (default 60 seconds).
// At the end of the cycle the number of metrics inserted is displayed.
func main() {
	goopt.Description = func() string {
		return "Go test writer program for MongoDB."
	}
	goopt.Version = "1.0"
开发者ID:davidkbainbridge,项目名称:writer,代码行数:31,代码来源:writer.go


示例9: Select

package promptcommit

import (
	"github.com/droundy/goopt"
	"../git/git"
	"../git/plumbing"
	"../util/out"
	"../util/error"
	"../util/exit"
	"../util/debug"
	box "./gotgo/box(git.CommitHash,git.Commitish)"
)

// To make --all the default, set *prompt.All to true.
var All = goopt.Flag([]string{"-a","--all"}, []string{"--interactive"},
	"verb all commits", "prompt for commits interactively")

var Dryrun = goopt.Flag([]string{"--dry-run"}, []string{},
	"just show commits that would be verbed", "xxxs")

var Verbose = goopt.Flag([]string{"-v","--verbose"}, []string{"-q","--quiet"},
	"output commits that are verbed", "don't output commits that are verbed")

func Select(since, upto git.Commitish) (outh git.CommitHash) {
	hs,e := plumbing.RevListDifference([]git.Commitish{upto}, []git.Commitish{since})
	error.FailOn(e)
	if len(hs) == 0 {
		out.Println(goopt.Expand("No commits to verb!"))
		exit.Exit(0)
	}
	if *Dryrun {
开发者ID:droundy,项目名称:iolaus,代码行数:31,代码来源:promptcommit.go


示例10: setup_logger

	if err != 0 {
		return 0, err1
	}

	// Handle exception for darwin
	if darwin && r2 == 1 {
		r1 = 0
	}

	return r1, 0

}

var config_file = goopt.String([]string{"-c", "--config"}, "/etc/ranger.conf", "config file")
var install_api_key = goopt.String([]string{"-i", "--install-api-key"}, "", "install api key")
var amForeground = goopt.Flag([]string{"--foreground"}, []string{"--background"}, "run foreground", "run background")

func setup_logger() {
	filename := "/var/log/ranger/ranger.log"

	// Create a default logger that is logging messages of FINE or higher to filename, no rotation
	//    log.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter(filename, false))

	// =OR= Can also specify manually via the following: (these are the defaults, this is equivalent to above)
	flw := l4g.NewFileLogWriter(filename, false)
	if flw == nil {
		fmt.Printf("No permission to write to %s, going to switch to stdout only\n", filename)
	} else {
		flw.SetFormat("[%D %T] [%L] (%S) %M")
		flw.SetRotate(false)
		flw.SetRotateSize(0)
开发者ID:pombredanne,项目名称:ranger-1,代码行数:31,代码来源:local_agent.go


示例11: log

import goopt "github.com/droundy/goopt"

import config "github.com/kless/goconfig/config"

var version = "0.1"

///////////////////////////////////
//
//		Taken form goopt example
//
///////////////////////////////////

// The Flag function creates a boolean flag, possibly with a negating
// alternative.  Note that you can specify either long or short flags
// naturally in the same list.
var amVerbose = goopt.Flag([]string{"-v", "--verbose"}, []string{"--quiet"},
	"output verbosely this will also show the graphite data", "be quiet, instead")

// This is just a logging function that uses the verbosity flags to
// decide whether or not to log anything.
func log(x ...interface{}) {
	if *amVerbose {
		fmt.Println(x...)
	}
}

///////////////////////////////////
///////////////////////////////////

func exists(path string) (bool, error) {
	_, err := os.Stat(path)
	if err == nil {
开发者ID:koumdros,项目名称:vnx2graphite,代码行数:32,代码来源:vnx2graphite.go


示例12: main

import (
	"bytes"
	"log"
	"net"
	"os/exec"
	"regexp"
	"strings"
	"time"

	"github.com/droundy/goopt"
)

var connect = goopt.String([]string{"-s", "--server"}, "127.0.0.1", "Server to connect to (and listen if listening)")
var port = goopt.Int([]string{"-p", "--port"}, 2222, "Port to connect to (and listen to if listening)")

var listen = goopt.Flag([]string{"-l", "--listen"}, []string{}, "Create a listening TFO socket", "")

func main() {

	goopt.Parse(nil)

	// IPv4 only for no real reason, could be v6 by adjusting the sizes
	// here and where it's used
	var serverAddr [4]byte

	IP := net.ParseIP(*connect)
	if IP == nil {
		log.Fatal("Unable to process IP: ", *connect)
	}

	copy(serverAddr[:], IP[12:16])
开发者ID:zgbkny,项目名称:tcp-fast-open,代码行数:31,代码来源:main.go


示例13: Run

package prompt

import (
	"github.com/droundy/goopt"
	"strings"
	"./core"
	"../git/color"
	"../util/out"
	"../util/error"
	"../util/debug"
	"../util/patience"
	ss "../util/slice(string)"
)

// To make --all the default, set *prompt.All to true.
var All = goopt.Flag([]string{"-a","--all"}, []string{"--interactive"},
	"verb all patches", "prompt for patches interactively")

func Run(ds []core.FileDiff, f func(core.FileDiff)) {
	if *All {
		for _,d := range ds {
			f(d)
		}
	} else {
	  files: for _,d := range ds {
			for {
				if !d.HasChange() {
					continue files
				}
				// Just keep asking until we get a reasonable answer...
				c,e := out.PromptForChar(goopt.Expand("Verb changes to %s? "), d.Name)
				error.FailOn(e)
开发者ID:droundy,项目名称:iolaus,代码行数:32,代码来源:prompt.go


示例14: optToRegion

import "fmt"
import "os"

import (
	goopt "github.com/droundy/goopt"
	"github.com/rhettg/ftl/ftl"
	"launchpad.net/goamz/aws"
	"path/filepath"
	"strings"
)

const DOWNLOAD_WORKERS = 4

const Version = "0.2.6"

var amVerbose = goopt.Flag([]string{"-v", "--verbose"}, []string{"--quiet"},
	"output verbosely", "be quiet, instead")

var amMaster = goopt.Flag([]string{"--master"}, nil, "Execute against master repository", "")

var amVersion = goopt.Flag([]string{"--version"}, nil, "Display current version", "")

func optToRegion(regionName string) (region aws.Region) {
	region = aws.USEast

	switch regionName {
	case "us-east":
		region = aws.USEast
	case "us-west-1":
		region = aws.USWest
	case "us-west-2":
		region = aws.USWest2
开发者ID:rhettg,项目名称:ftl,代码行数:32,代码来源:main.go


示例15: main

package main

import (
	"fmt"
	goopt "github.com/droundy/goopt"
	"github.com/xaviershay/erg"
	"os"
	"strconv"
)

var port = goopt.Int([]string{"-p", "--port"}, 8080, "Port to connect to. Can also be set with RANGE_PORT environment variable.")
var host = goopt.String([]string{"-h", "--host"}, "localhost", "Host to connect to. Can also be set with RANGE_HOST environment variable.")
var ssl = goopt.Flag([]string{"-s", "--ssl"}, []string{"--no-ssl"},
	"Don't use SSL", "Use SSL. Can also be set with RANGE_SSL environment variable.")
var expand = goopt.Flag([]string{"-e", "--expand"}, []string{"--no-expand"},
	"Do not compress results", "Compress results (default)")

func main() {
	if envHost := os.Getenv("RANGE_HOST"); len(envHost) > 0 {
		*host = envHost
	}

	if envSsl := os.Getenv("RANGE_SSL"); len(envSsl) > 0 {
		*ssl = true
	}

	if envPort := os.Getenv("RANGE_PORT"); len(envPort) > 0 {
		x, err := strconv.Atoi(envPort)
		if err == nil {
			*port = x
		} else {
开发者ID:xaviershay,项目名称:erg,代码行数:31,代码来源:erg.go


示例16: main

func main() {
	goopt.Summary = "Command line tool to merge minimaps from custom clients in Hafen."
	var sessionFodler = goopt.StringWithLabel([]string{"-d", "--sessions-dir"}, "sessions", "<path>",
		"Specify input folder (instead of default \"sessions\")")
	var mode = goopt.Alternatives([]string{"-m", "--mode"}, []string{"merger", "zoomer", "picture"},
		"Specify mode (instead of default \"merger\")")
	var zoomPath = goopt.StringWithLabel([]string{"-z", "--zoom"}, "", "<session>",
		"Create zoom layers for specific <session> and place them into \"zoommap\" folder")
	var zoomSize = goopt.IntWithLabel([]string{"--zoom-tile-size"}, 100, "<size>",
		"Specify generated tiles size (instead of default 100)")
	var zoomMax = goopt.IntWithLabel([]string{"--zoom-max"}, 5, "<num>",
		"Specify zoom max (instead of default 5)")
	var zoomMin = goopt.IntWithLabel([]string{"--zoom-min"}, 1, "<num>",
		"Specify zoom min (instead of default 1)")
	var picturePath = goopt.StringWithLabel([]string{"-p", "--picture"}, "", "<session>",
		"Create single map picture for specific <session>")
	var outputFodler = goopt.StringWithLabel([]string{"-o", "--output-dir"}, "zoommap", "<path>",
		"Specify output folder for zoom mode (instead of default \"zoommap\")")
	var trimSessions = goopt.IntWithLabel([]string{"-t", "--trim"}, -1, "<count>",
		"Remove sessions with tiles < <count> from result (good for removing cave sessions)")
	var removeNonStandard = goopt.Flag([]string{"-c", "--clean-non-standard"}, []string{},
		"Remove all non-standard maps (size != 100x100)", "")
	var hashCode = goopt.Alternatives([]string{"--hash-method"}, []string{"simple", "border"},
		"Specify hash method (instead of default \"simple\")")

	// Parse CMD
	goopt.Parse(nil)

	// Force change mode for backward compatibility
	if *picturePath != "" && *mode == "merger" {
		*mode = "picture"
	}
	if *zoomPath != "" && *mode == "merger" {
		*mode = "zoomer"
	}

	SESSION_FOLDER = *sessionFodler

	var hashMethod HashMethod
	switch *hashCode {
	case "simple":
		hashMethod = HashMethod{CodeName: *hashCode, Func: generateSimpleHash}
		break
	case "border":
		hashMethod = HashMethod{CodeName: *hashCode, Func: generateBorderHash}
		break
	default:
		panic("Unrecognized hash method!") // this should never happen!
	}

	workingDirectory, _ := filepath.Abs(SESSION_FOLDER)

	if *zoomSize%100 != 0 {
		fmt.Println("Tile size must be in multiples of 100")
		return
	}
	var composeCount = int(*zoomSize / 100)

	// Generate zoom levels for specific session
	if *mode == "zoomer" {
		generateTiles(workingDirectory, *zoomPath, *outputFodler, composeCount, hashMethod, *zoomMin, *zoomMax)
		return
	}

	// Generate single picture for specific session
	if *mode == "picture" {
		generatePicture(workingDirectory, *picturePath)
		return
	}

	// Otherwise, let's make cross-merge
	files, _ := ioutil.ReadDir(workingDirectory)
	if len(files) < 2 {
		fmt.Println("No folders found")
		return
	}

	if *removeNonStandard == true {
		// Remove all sessions with tile size != 100x100
		for j := 0; j < len(files); j++ {
			tiles, _ := ioutil.ReadDir(filepath.Join(workingDirectory, files[j].Name()))
			for i := 0; i < len(tiles); i++ {
				if strings.Contains(tiles[i].Name(), "tile_") {
					sx, sy := getImageDimension(filepath.Join(workingDirectory, files[j].Name(), tiles[i].Name()))
					if sx != 100 || sy != 100 {
						fmt.Printf("Old session removed: %s\n", files[j].Name())
						os.RemoveAll(filepath.Join(workingDirectory, files[j].Name()))
					}
					break
				}
			}
		}
	}

	files, _ = ioutil.ReadDir(workingDirectory)
	if len(files) < 2 {
		fmt.Println("No folders found")
		return
	}
	for j := 0; j < len(files); j++ {
//.........这里部分代码省略.........
开发者ID:APXEOLOG,项目名称:hafen-map-tool,代码行数:101,代码来源:map-merger.go


示例17:

	"fmt"
	"github.com/droundy/goopt"
	"github.com/wsxiaoys/terminal/color"
	"os"
	"path/filepath"
	"regexp"
)

var (
	Author  = "Alexander Solovyov"
	Version = "0.4.3"
	Summary = "gr [OPTS] string-to-search\n"

	byteNewLine []byte = []byte("\n")

	ignoreCase = goopt.Flag([]string{"-i", "--ignore-case"}, []string{},
		"ignore pattern case", "")
	onlyName = goopt.Flag([]string{"-n", "--filename"}, []string{},
		"print only filenames", "")
	ignoreFiles = goopt.Strings([]string{"-x", "--exclude"}, "RE",
		"exclude files that match the regexp from search")
	singleline = goopt.Flag([]string{"-s", "--singleline"}, []string{},
		"match on a single line (^/$ will be beginning/end of line)", "")
	plaintext = goopt.Flag([]string{"-p", "--plain"}, []string{},
		"search plain text", "")
	replace = goopt.String([]string{"-r", "--replace"}, "",
		"replace found substrings with this string")
	force = goopt.Flag([]string{"--force"}, []string{},
		"force replacement in binary files", "")
	showVersion = goopt.Flag([]string{"-V", "--version"}, []string{},
		"show version and exit", "")
	noIgnoresGlobal = goopt.Flag([]string{"-I", "--no-autoignore"}, []string{},
开发者ID:jwhitlark,项目名称:goreplace,代码行数:32,代码来源:goreplace.go


示例18: panicon

package main

import (
	"exec"
	"fmt"
	"github.com/droundy/go-crazy/parser"
	"github.com/droundy/goopt"
	"go/printer"
	"os"
)

var just_translate = goopt.Flag([]string{"--just-translate"}, []string{},
	"just build the -compiled.go file", "build and compile and link")

var toinline = goopt.Strings([]string{"--inline"}, "FUNC", "specify function to inline")

func panicon(err os.Error) {
	if err != nil {
		panic(err)
	}
}

func archnum() string {
	switch os.Getenv("GOARCH") {
	case "386":
		return "8"
	case "amd64":
		return "6"
		// what was the other one called?
	}
	return "5"
开发者ID:droundy,项目名称:go-crazy,代码行数:31,代码来源:go-crazy.go


示例19: main

package main

// test out the goopt package...

import (
	"fmt"
	goopt "github.com/droundy/goopt"
	"strings"
)

var amVerbose = goopt.Flag([]string{"--verbose"}, []string{},
	"output verbosely", "")
var amHappy = goopt.Flag([]string{"-h", "--happy"}, []string{"-u", "--unhappy", "--sad"}, "be happy", "be unhappy")

var foo = goopt.String([]string{"--name"}, "anonymous", "pick your name")
var bar = goopt.String([]string{"-b"}, "BOO!", "pick your scary sound")
var baz = goopt.String([]string{"-o"}, "", "test whether a silent default works")
var speed = goopt.Alternatives([]string{"--speed", "--velocity"},
	[]string{"slow", "medium", "fast"},
	"set the speed")

var words = goopt.Strings([]string{"--word", "--saying", "-w", "-s"}, "word",
	"specify a word to speak")

var width = goopt.Int([]string{"-l", "--length"}, 1, "number of ?s")

func main() {
	goopt.Summary = "silly test program"
	goopt.Parse(nil)
	if *amVerbose {
		fmt.Println("I am verbose.")
开发者ID:endurox-dev,项目名称:goopt,代码行数:31,代码来源:test-program.go


示例20:

  limitations under the License.
*/

package main

import (
	"fmt"
	goopt "github.com/droundy/goopt"
	"os"
	"strconv"
	"strings"
	"time"
)

// Actions
var addFlag = goopt.Flag([]string{"-a", "--add"}, nil, "add a task", "")
var editFlag = goopt.Flag([]string{"-e", "--edit"}, nil, "edit a task, replacing its text", "")
var markDoneFlag = goopt.Flag([]string{"-d", "--done"}, nil, "mark the given tasks as done", "")
var markNotDoneFlag = goopt.Flag([]string{"-D", "--not-done"}, nil, "mark the given tasks as not done", "")
var removeFlag = goopt.Flag([]string{"--remove"}, nil, "remove the given tasks", "")
var reparentFlag = goopt.Flag([]string{"-R", "--reparent"}, nil, "reparent task A below task B", "")
var titleFlag = goopt.Flag([]string{"--title"}, nil, "set the task list title", "")
var versionFlag = goopt.Flag([]string{"--version"}, nil, "show version", "")
var infoFlag = goopt.Flag([]string{"-i", "--info"}, nil, "show information on a task", "")
var importFlag = goopt.Flag([]string{"--import"}, nil, "import and synchronise TODO items from source code", "")

// Options
var priorityFlag = goopt.String([]string{"-p", "--priority"}, "medium", "priority of newly created tasks (veryhigh,high,medium,low,verylow)")
var graftFlag = goopt.String([]string{"-g", "--graft"}, "root", "task to graft new tasks to")
var fileFlag = goopt.String([]string{"--file"}, ".todo2", "file to load task lists from")
var legacyFileFlag = goopt.String([]string{"--legacy-file"}, ".todo", "file to load legacy task lists from")
开发者ID:rdmo,项目名称:devtodo2,代码行数:31,代码来源:main.go



注:本文中的github.com/droundy/goopt.Flag函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang goopt.Help函数代码示例发布时间:2022-05-23
下一篇:
Golang generator.PluginImports类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap