本文整理汇总了Golang中github.com/alecthomas/kingpin.Flag函数的典型用法代码示例。如果您正苦于以下问题:Golang Flag函数的具体用法?Golang Flag怎么用?Golang Flag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Flag函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
//Parse command line flags
var (
_host = kingpin.Flag("host", "Hostname").Short('h').Required().String()
_port = kingpin.Flag("port", "Port number").Short('p').Required().Int()
_threads = kingpin.Flag("threads", "Thread count").Short('t').Default("1").Int()
_size = kingpin.Flag("size", "Packet Size").Short('s').Default("65507").Int()
)
kingpin.Parse()
fullAddr := fmt.Sprintf("%s:%v", *_host, *_port)
//Create send buffer
var buf []byte = make([]byte, *_size)
//Establish udp
conn, err := net.Dial("udp", fullAddr)
if err != nil {
fmt.Println(err)
} else {
fmt.Printf("Flooding %s\n", fullAddr)
for i := 0; i < *_threads; i++ {
go func() {
for {
conn.Write(buf)
}
}()
}
}
//Sleep forever
<-make(chan bool, 1)
}
开发者ID:TWSSYesterday,项目名称:udpflood,代码行数:32,代码来源:udpflood.go
示例2: init
func init() {
m = macaron.Classic()
m.Use(modules.Public)
m.Use(modules.Renderer)
kingpin.HelpFlag.Short('h')
kingpin.Flag("port", "Port to listen").Default("8000").IntVar(&gcfg.port)
kingpin.Flag("root", "File root directory").Default(".").StringVar(&gcfg.root)
kingpin.Flag("private", "Only listen on loopback address").BoolVar(&gcfg.private)
kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.httpauth)
kingpin.Flag("cert", "TLS cert.pem").StringVar(&gcfg.cert)
kingpin.Flag("key", "TLS key.pem").StringVar(&gcfg.key)
kingpin.Flag("gzip", "Enable Gzip support").BoolVar(&gcfg.gzip)
kingpin.Flag("ftp", "Enable FTP support").BoolVar(&gcfg.ftp)
kingpin.Flag("ftp-port", "FTP listen port").Default("2121").IntVar(&gcfg.ftpPort)
kingpin.Flag("ftp-auth", "FTP auth (ex: user:pass)").Default("admin:123456").StringVar(&gcfg.ftpAuth)
}
开发者ID:JackHooke,项目名称:gohttp,代码行数:17,代码来源:main.go
示例3: main
func main() {
// Setup context
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Define a CLI
dcConfig := &DCConfig{ServiceIdentifier: "omnivore"}
kingpin.Flag("n", "The index of this node in the pool, if IPFS_POOL_PATH is set").Default("-1").Short('n').IntVar(&dcConfig.PoolIndex)
var args []string
kingpin.Arg("args", "arguments").StringsVar(&args)
kingpin.Parse()
// Build a node
ipfsNode, err := BuildNode(ctx, dcConfig)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("I am node %s\n", ipfsNode.Identity.Pretty())
// Respond to incoming providerIDs and streams
// providerIDsIn, err := StartServiceDiscovery(ctx, ipfsNode, dcConfig)
// if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
//
// streamIn, err := StartListening(ipfsNode, dcConfig)
// if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
//
// for {
// select {
// case providerIDs := <-providerIDsIn:
// for _, providerID := range providerIDs {
// fmt.Printf("Provider: %s\n", providerID.Pretty())
//
// stream, err := corenet.Dial(ipfsNode, providerID, dcConfig.ServiceIdentifier)
// if err != nil {
// fmt.Printf("Failed to dial provider %s (%s)\n", providerID.Pretty(), err)
// continue
// }
//
// fmt.Fprintf(stream, "Hello! I'm peer %s\n", ipfsNode.Identity.Pretty())
// stream.Close()
// }
//
// case stream := <-streamIn:
// fmt.Printf("Peer %s called!\n", stream.Conn().RemotePeer().Pretty())
// }
// }
}
开发者ID:confiks,项目名称:ipfs-dc,代码行数:57,代码来源:main.go
示例4: main
func main() {
bsize := kingpin.Flag("blocksize", "blocksize to test with").Default("262144").Int64()
kingpin.Parse()
ipfsdir := getIpfsDir()
r, err := fsrepo.Open(ipfsdir)
if err != nil {
fmt.Printf("Failed to open ipfs repo at: %s: %s\n", ipfsdir, err)
fmt.Println("Please ensure ipfs has been initialized and that no daemon is running")
return
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
nd, err := core.NewNode(ctx, &core.BuildCfg{
Repo: r,
})
if err != nil {
fmt.Printf("failed to create node: %s\n", err)
return
}
cfg := &BenchCfg{
Blocksize: *bsize,
}
fmt.Println(cfg)
err = BenchmarkBlockRewrites(nd, cfg)
if err != nil {
panic(err)
}
err = BenchmarkRandomBlockWrites(nd, cfg)
if err != nil {
panic(err)
}
err = BenchmarkAdd(nd, cfg)
if err != nil {
panic(err)
}
err = BenchmarkDiskWrites(ipfsdir)
if err != nil {
panic(err)
}
}
开发者ID:whyrusleeping,项目名称:repobench,代码行数:48,代码来源:main.go
示例5: Set
"encoding/binary"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"strings"
"github.com/alecthomas/kingpin"
"github.com/chzyer/readline"
"github.com/joushou/qp"
"github.com/joushou/qptools/client"
)
var (
service = kingpin.Flag("service", "service name to use when connecting (aname)").Short('s').String()
user = kingpin.Flag("user", "username to use when connecting (uname)").Short('u').String()
address = kingpin.Arg("address", "address to connect to").Required().String()
command = stringList(kingpin.Arg("command", "command to execute (disables interactive mode)"))
rawtls = kingpin.Flag("rawtls", "wrap connection in TLS").Short('t').Bool()
)
type slist []string
func (i *slist) Set(value string) error {
*i = append(*i, value)
return nil
}
func (i *slist) String() string {
return ""
开发者ID:joushou,项目名称:qptools,代码行数:31,代码来源:main.go
示例6:
*/
import (
"fmt"
"github.com/alecthomas/kingpin"
"github.com/cathalgarvey/go-minilock"
"github.com/cathalgarvey/go-minilock/taber"
"github.com/howeyc/gopass"
"io/ioutil"
)
var (
encrypt = kingpin.Command("encrypt", "Encrypt a file.")
decrypt = kingpin.Command("decrypt", "Decrypt a file.")
PassPhrase = kingpin.Flag("passphrase", "Full passphrase for this miniLock key. If not given through this flag, it will be asked for interactively").
Short('p').String()
OutputFileName = kingpin.Flag("output", "Name of output file. By default for encryption, this is input filename + '.minilock', and for decryption this is the indicated filename in the ciphertext. Warning: Right now this presents potential security hazards!").
Short('o').Default("NOTGIVEN").String()
efile = encrypt.Arg("file", "File to encrypt or decrypt.").Required().String()
dfile = decrypt.Arg("file", "File to encrypt or decrypt.").Required().String()
eUserEmail = encrypt.
Arg("user-email", "Your email address. This need not be secret, but if this isn't *accurate* it must be *globally unique*, it is used for generating security.").
Required().String()
dUserEmail = decrypt.
Arg("user-email", "Your email address. This need not be secret, but if this isn't *accurate* it must be *globally unique*, it is used for generating security.").
Required().String()
recipients = encrypt.Arg("recipients", "One or more miniLock IDs to add to encrypted file.").Strings()
开发者ID:nekrondev,项目名称:go-minilock,代码行数:31,代码来源:main.go
示例7: Flag
func Flag(name string, helpOptional ...string) *kingpin.FlagClause {
help := strings.Join(helpOptional, " ")
return kingpin.Flag(name, help)
}
开发者ID:marcuswestin,项目名称:go-cli,代码行数:4,代码来源:cli-args.go
示例8: parseFlags
func parseFlags() {
kingpin.HelpFlag.Short('h')
kingpin.Version(versionMessage())
kingpin.Flag("root", "root directory").Short('r').Default("./").StringVar(&gcfg.Root)
kingpin.Flag("addr", "listen address").Short('a').Default(":8000").StringVar(&gcfg.Addr)
kingpin.Flag("cert", "tls cert.pem path").StringVar(&gcfg.Cert)
kingpin.Flag("key", "tls key.pem path").StringVar(&gcfg.Key)
kingpin.Flag("httpauth", "HTTP basic auth (ex: user:pass)").Default("").StringVar(&gcfg.HttpAuth)
kingpin.Flag("theme", "web theme, one of <black|green>").Default("black").StringVar(&gcfg.Theme)
kingpin.Flag("upload", "enable upload support").BoolVar(&gcfg.Upload)
kingpin.Flag("xheaders", "used when behide nginx").BoolVar(&gcfg.XHeaders)
kingpin.Flag("cors", "enable cross-site HTTP request").BoolVar(&gcfg.Cors)
kingpin.Flag("plistproxy", "plist proxy when server is not https").Default(defaultPlistProxy).Short('p').URLVar(&gcfg.PlistProxy)
kingpin.Flag("title", "server title").Default("Go HTTP File Server").StringVar(&gcfg.Title)
kingpin.Parse()
}
开发者ID:RainYang0925,项目名称:gohttpserver,代码行数:17,代码来源:main.go
示例9: main
import (
"log"
"os"
"os/user"
"path/filepath"
"strconv"
"syscall"
"github.com/alecthomas/kingpin"
"github.com/go-fsnotify/fsnotify"
)
var (
cliDir = kingpin.Arg("dir", "The directory to enforce permissions.").Required().String()
cliChownUser = kingpin.Flag("chown-user", "Name of the user to Chown the directory with.").Required().String()
cliChownGroup = kingpin.Flag("chown-group", "Name of group to Chown the directory with.").Required().String()
cliChmodDir = kingpin.Flag("chmod-dir", "The mode to be assigned to directories.").Default("0775").Int64()
cliChmodFile = kingpin.Flag("chmod-file", "The mode to be assigned to files.").Default("0664").Int64()
uid int
gid int
)
func main() {
kingpin.Parse()
u, err := user.Lookup(*cliChownUser)
if err != nil {
panic(err)
}
开发者ID:nickschuch,项目名称:permissions,代码行数:30,代码来源:main.go
示例10: main
import (
"os"
log "github.com/Sirupsen/logrus"
"github.com/alecthomas/kingpin"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/lox/lifecycled"
)
const (
simulateQueue = "simulate"
)
var (
verbose = kingpin.Flag("verbose", "Verbose mode.").Short('v').Bool()
instanceID = kingpin.Flag("instanceid", "An instanceid to use to filter messages").String()
sqsQueue = kingpin.Flag("queue", "The sqs queue identifier to consume").Required().String()
handler = kingpin.Flag("handler", "The script to invoke to handle events").Required().File()
debug = kingpin.Flag("debug", "Show debugging info").Bool()
)
func main() {
log.SetFormatter(&log.TextFormatter{})
kingpin.CommandLine.DefaultEnvars()
kingpin.Parse()
var queue lifecycled.Queue
// provide a simulated queue for testing
开发者ID:justinhennessy,项目名称:lifecycled,代码行数:31,代码来源:main.go
示例11: findUser
"os"
"os/signal"
"strings"
"syscall"
"time"
"github.com/alecthomas/kingpin"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/bluele/slack"
)
const filename = "notified.json"
var token = kingpin.Flag("token", "The slack API token").OverrideDefaultFromEnvar("TOKEN").Required().String()
var timeout = kingpin.Arg("wait", "Wait in minutes before checking for changes").Default("10").Int()
var expireTime = kingpin.Arg("expire", "Age in hours before notifing about the instance").Default("48").Int()
var region = kingpin.Arg("region", "Amazon EC2 region to scan for instances").Default("eu-west-1").String()
var prod = kingpin.Flag("prod", "Running for real?").OverrideDefaultFromEnvar("PROD").Default("false").Bool()
func findUser(list []*slack.User, searchid string) string {
for _, u := range list {
if u.Id == searchid {
return u.Id
}
if u.Profile.Email != "" {
data := strings.Split(u.Profile.Email, "@")
if data[0] == searchid {
return u.Id
开发者ID:sorenmat,项目名称:botbrother,代码行数:31,代码来源:main.go
示例12: main
//"github.com/davecgh/go-spew/spew" // For neatly outputting stuff
//"strconv" // For String construction
//"time" // Used as part of "setInterval" and for pausing code to allow for data to come back
//"fmt" //Output stuff to the screen
"github.com/alecthomas/kingpin"
"github.com/juju/loggo"
//"github.com/rcrowley/go-metrics"
)
//const statsTopic = "$device/stats"
const wbTopic = "$device/wb"
var (
debug = kingpin.Flag("debug", "Enable debug mode.").OverrideDefaultFromEnvar("DEBUG").Bool()
daemon = kingpin.Flag("daemon", "Run in daemon mode.").Short('d').Bool()
mqttURL = kingpin.Flag("mqttUrl", "The MQTT url to publish too.").Short('u').Default("tcp://localhost:1883").String()
logName = kingpin.Flag("logName", "The Log Name.").Short('u').Default("webbrick-mqtt").String()
//port = kingpin.Flag("port", "HTTP Port.").Short('i').OverrideDefaultFromEnvar("PORT").Default("9980").Int()
//path = kingpin.Flag("path", "Path to static content.").Short('p').OverrideDefaultFromEnvar("CONTENT_PATH").Default("./public").String()
interval = kingpin.Flag("interval", "Publish interval.").Short('i').Default("30").Int()
//log = loggo.GetLogger("mqtt_webbrick")
)
func main() {
kingpin.Version(Version)
kingpin.Parse()
setupLoggo(*debug)
开发者ID:paulcull,项目名称:mqtt-webbrick,代码行数:30,代码来源:main.go
示例13: main
import (
"fmt"
"os"
"github.com/alecthomas/kingpin"
"github.com/parnurzeal/gorequest"
"github.com/toqueteos/webbrowser"
)
const htmlURL string = "http://kaifa.at/services/"
const jsonURL string = "http://kaifa.at/api/services/"
var (
keyword = kingpin.Arg("keyword", "Keyword of service").Required().String()
format = kingpin.Flag("format", "Format: html,json").Default("html").String()
)
func main() {
kingpin.Version("0.2.1")
kingpin.Parse()
switch *format {
case "html":
openBrowser()
case "json":
fetchJSON()
default:
openBrowser()
}
}
开发者ID:kaifali,项目名称:cli,代码行数:30,代码来源:kaifa.go
示例14: onMessage
// Program gcm-logger logs and echoes as a GCM "server".
package main
import (
"github.com/alecthomas/kingpin"
"github.com/aliafshar/toylog"
"github.com/google/go-gcm"
)
var (
serverKey = kingpin.Flag("server_key", "The server key to use for GCM.").Short('k').Required().String()
senderId = kingpin.Flag("sender_id", "The sender ID to use for GCM.").Short('s').Required().String()
)
// onMessage receives messages, logs them, and echoes a response.
func onMessage(cm gcm.CcsMessage) error {
toylog.Infoln("Message, from:", cm.From, "with:", cm.Data)
// Echo the message with a tag.
cm.Data["echoed"] = true
m := gcm.HttpMessage{To: cm.From, Data: cm.Data}
r, err := gcm.SendHttp(*serverKey, m)
if err != nil {
toylog.Errorln("Error sending message.", err)
return err
}
toylog.Infof("Sent message. %+v -> %+v", m, r)
return nil
}
func main() {
toylog.Infoln("GCM Logger, starting.")
开发者ID:ciarand,项目名称:go-gcm,代码行数:31,代码来源:gcm-logger.go
示例15: main
"github.com/alecthomas/kingpin"
"github.com/go-martini/martini"
"github.com/jmoiron/sqlx"
"github.com/martini-contrib/gzip"
"github.com/martini-contrib/method"
)
const TestString = "Umse ♪"
var templateManager *TemplateManager
var restrictionHandlers map[string]RestrictionHandler
var config *configuration
var sessions *SessionMiddleware
var (
password = kingpin.Flag("password", "Encryption key in plain text (discouraged)").String()
configFile = kingpin.Flag("config", "Configuration file to use").ExistingFile()
)
func main() {
kingpin.UsageTemplate(kingpin.CompactUsageTemplate).Version("1.0").Author("Christoph Mewes")
kingpin.CommandLine.Help = "HTTP application server to run the Raziel secret management"
kingpin.Parse()
if *configFile == "" {
kingpin.FatalUsage("No configuration file (--config) given!")
}
// load config file
err := loadConfigFile()
if err != nil {
开发者ID:xrstf,项目名称:raziel,代码行数:31,代码来源:main.go
示例16:
"runtime"
"strconv"
"time"
"github.com/alecthomas/kingpin"
"github.com/codeskyblue/gopsutil/android"
"github.com/codeskyblue/gopsutil/process"
)
var (
VERSION = "0.0.x"
BUILD_DATE = "unknown"
)
var (
search = kingpin.Flag("proc", "Find process, support ex: pid:71, exe:/bin/ls, cmdline:./ps").Short('p').String()
showInfo = kingpin.Flag("info", "Show phone info and exit").Short('i').Bool()
showFPS = kingpin.Flag("fps", "Show fps in android").Bool()
version = kingpin.Flag("version", "Show version").Short('v').Bool()
duration = kingpin.Flag("duration", "Collection interval").Short('d').Default("1s").Duration()
listen = kingpin.Flag("listen", "Listen http request").Short('l').Bool()
port = kingpin.Flag("port", "Listen port").Default("16118").Int()
test = kingpin.Flag("test", "Run test program, only for develop").Bool()
quit = kingpin.Flag("quit", "Quit running program").Bool()
//search = flag.String("p", "",
// "Search process, support ex: pid:71, exe:/usr/bin/ls, cmdline:./ps")
//showInfo = flag.Bool("i", false, "Show mathine infomation")
//showFPS = flag.Bool("fps", false, "Show fps of android")
//version = flag.Bool("v", false, "Show version")
//duration = flag.Duration("d", time.Second, "Collect interval")
//listen = flag.Bool("l", false, "Listen http request data")
开发者ID:codeskyblue,项目名称:gopsutil,代码行数:31,代码来源:main.go
示例17:
package main
import (
"github.com/alecthomas/kingpin"
"github.com/cathalgarvey/buckfast/scrapedia"
"github.com/cathalgarvey/buckfast/spritzlib"
"io/ioutil"
"log"
"strings"
)
var (
infile = kingpin.Arg("infile", "File to read. If prefixed with 'wikipedia:', fetches the corresponding wikipedia page instead (needs to be exact target page title)").Required().String()
wpm = kingpin.Flag("wpm", "Approximate words per minute").Default("400").Short('w').Int()
pivotColour = kingpin.Flag("pivot-colour", "Preferred pivot colour, one of red, green, blue, yellow, cyan, magenta, white, black.").
Default("green").
Short('p').
Enum("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white")
//String()
plainColour = kingpin.Flag("plain-colour", "Preferred non-pivot text colour, one of red, green, blue, yellow, cyan, magenta, white, black.").
Default("white").
Short('P').
Enum("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white")
// String()
bgColour = kingpin.Flag("background-colour", "Text background colour, one of red, green, blue, yellow, cyan, magenta, white, black.").
Default("").
Short('b').
Enum("red", "green", "blue", "cyan", "magenta", "yellow", "black", "white")
// String()
boldText = kingpin.Flag("bold", "Whether to print bold.").Bool()
)
开发者ID:cathalgarvey,项目名称:buckfast,代码行数:31,代码来源:main.go
示例18: main
package main
import (
// "encoding/json"
// "fmt"
log "github.com/Sirupsen/logrus"
"github.com/alecthomas/kingpin"
"os"
"path/filepath"
)
var (
osd_sockets = kingpin.Flag("osd_sock", "pattern for osd sockets").Default("/var/run/ceph/osd*asok").String()
mon_sockets = kingpin.Flag("mon_sock", "pattern for mon sockets").Default("/var/run/ceph/mon*asok").String()
conf = kingpin.Flag("conf", "path to configuration file").Default("/etc/ceph/ceph.conf").String()
verbose = kingpin.Flag("verbose", "verbose logging").Short('v').Bool()
logfile = kingpin.Flag("log", "path to logfile").Default("/var/log/ceph/rlyeh.log").String()
)
type perf struct {
PerfCounter
error
}
func main() {
kingpin.Version("0.1")
kingpin.Parse()
f, err := os.OpenFile(*logfile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
开发者ID:hkumarmk,项目名称:rlyeh,代码行数:31,代码来源:main.go
示例19: main
package main
import (
"github.com/alecthomas/kingpin"
"github.com/alexandre-normand/slackscot"
"github.com/alexandre-normand/slackscot/brain"
"github.com/alexandre-normand/slackscot/config"
"log"
)
var (
configurationPath = kingpin.Flag("configuration", "The path to the configuration file.").Required().String()
)
func main() {
kingpin.Parse()
config, err := config.LoadConfiguration(*configurationPath)
if err != nil {
log.Fatal(err)
}
youppi := slackscot.NewSlackscot([]slackscot.ExtentionBundle{brain.NewKarma(), brain.NewImager(), brain.NewFingerQuoter(), brain.NewEmojiBannerMaker()})
err = slackscot.Run(*youppi, *config)
if err != nil {
log.Fatal(err)
}
}
开发者ID:alexandre-normand,项目名称:youppi,代码行数:29,代码来源:youppi.go
示例20: main
package main
import (
"strings"
"time"
"github.com/alecthomas/kingpin"
)
var (
train = kingpin.Flag("train", "Enable train model").Short('t').Bool()
model = kingpin.Flag("model", "HMM Trained Model").Short('m').Required().String()
text = kingpin.Flag("text", "Text to process").Short('t').Required().String()
)
func main() {
kingpin.Parse()
if *train {
println("START")
start := time.Now().UnixNano()
ptrain := NewHMMParser("training/training.set")
println("Training set loaded")
ptrain.fParseTrainer()
println("Training set trained")
ptrain.Save()
stop := time.Now().UnixNano()
println("training delta", (stop-start)/1000, "mics")
} else {
println("Loading model " + *model)
hmmParser := NewHMMParser(*model)
hmmParser.Load()
开发者ID:lessc0de,项目名称:go-postagger,代码行数:31,代码来源:gopostagger.go
注:本文中的github.com/alecthomas/kingpin.Flag函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论