本文整理汇总了Golang中github.com/codegangsta/cli.Context.GlobalBool方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.GlobalBool方法的具体用法?Golang Context.GlobalBool怎么用?Golang Context.GlobalBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.GlobalBool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: loadFactory
// loadFactory returns the configured factory instance for execing containers.
func loadFactory(context *cli.Context) (libcontainer.Factory, error) {
var (
debug = "false"
root = context.GlobalString("root")
)
if context.GlobalBool("debug") {
debug = "true"
}
abs, err := filepath.Abs(root)
if err != nil {
return nil, err
}
logAbs, err := filepath.Abs(context.GlobalString("log"))
if err != nil {
return nil, err
}
return libcontainer.New(abs, libcontainer.Cgroupfs, func(l *libcontainer.LinuxFactory) error {
l.CriuPath = context.GlobalString("criu")
return nil
},
libcontainer.InitArgs(os.Args[0],
"--log", logAbs,
"--log-format", context.GlobalString("log-format"),
fmt.Sprintf("--debug=%s", debug),
"init"),
)
}
示例2: createImageCommandFunc
func createImageCommandFunc(c *cli.Context) {
var image string
if len(c.Args()) == 0 {
log.Fatal("You need to specify a image")
} else {
image = c.Args()[0]
}
clnt := client.New(c.GlobalString("server"))
if c.GlobalBool("debug") {
clnt.SetDebug()
}
s := client.Image{
Image: image,
Type: prompt.String("Type", prompt.Prompt{Default: "docker", FuncPtr: prompt.Enum, FuncInp: "file,docker"}),
BootTagID: *chooseTag(clnt, ""),
}
// Is this correct?
fmt.Println(string(s.JSON()))
if !prompt.Bool("Is this correct", true) {
os.Exit(1)
}
// Create image
clnt.Image.Create(&s)
}
示例3: MakeChain
// MakeChain creates a chain manager from set command line flags.
func MakeChain(ctx *cli.Context) (chain *core.ChainManager, chainDb common.Database) {
datadir := ctx.GlobalString(DataDirFlag.Name)
cache := ctx.GlobalInt(CacheFlag.Name)
var err error
if chainDb, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "chaindata"), cache); err != nil {
Fatalf("Could not open database: %v", err)
}
if ctx.GlobalBool(OlympicFlag.Name) {
InitOlympic()
_, err := core.WriteTestNetGenesisBlock(chainDb, 42)
if err != nil {
glog.Fatalln(err)
}
}
eventMux := new(event.TypeMux)
pow := ethash.New()
//genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB)
chain, err = core.NewChainManager(chainDb, nil, pow, eventMux)
if err != nil {
Fatalf("Could not start chainmanager: %v", err)
}
proc := core.NewBlockProcessor(chainDb, pow, chain, eventMux)
chain.SetProcessor(proc)
return chain, chainDb
}
示例4: BeforeApp
func BeforeApp(c *cli.Context) error {
if c.GlobalBool("verbose") {
logrus.SetLevel(logrus.DebugLevel)
}
logrus.Warning("Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose)")
return nil
}
示例5: preload
func preload(context *cli.Context) error {
if context.GlobalBool("debug") {
logger.Level = logrus.DebugLevel
}
config = loadConfig(context.GlobalString("config"))
return nil
}
示例6: updateSiteCommandFunc
func updateSiteCommandFunc(c *cli.Context) {
if len(c.Args()) == 0 {
log.Fatal("You need to specify a site")
}
site := c.Args()[0]
clnt := client.New(c.GlobalString("server"))
if c.GlobalBool("debug") {
clnt.SetDebug()
}
v, err := clnt.Site.Get(site)
if err != nil {
log.Fatal(err.Error())
}
s := client.Site{
ID: v.ID,
Site: prompt.String("Site", prompt.Prompt{Default: v.Site, FuncPtr: prompt.Regex, FuncInp: ""}),
Domain: prompt.String("Domain", prompt.Prompt{Default: v.Domain, FuncPtr: prompt.Regex, FuncInp: ""}),
DNS: strings.Split(prompt.String("DNS", prompt.Prompt{Default: strings.Join(v.DNS, ","), FuncPtr: validateIPv4List, FuncInp: ""}), ","),
DockerRegistry: prompt.String("Docker Registry", prompt.Prompt{Default: v.DockerRegistry, FuncPtr: prompt.Regex, FuncInp: ""}),
ArtifactRepository: prompt.String("Artifact Repository", prompt.Prompt{Default: v.ArtifactRepository, FuncPtr: prompt.Regex, FuncInp: ""}),
NamingScheme: prompt.String("Naming Scheme", prompt.Prompt{Default: v.NamingScheme, FuncPtr: prompt.Enum, FuncInp: "serial-number,hardware-address,external"}),
PXETheme: prompt.String("PXE Theme", prompt.Prompt{Default: v.PXETheme, FuncPtr: prompt.Regex, FuncInp: ""}),
}
// Create site
clnt.Site.Update(site, &s)
}
示例7: newTransmitter
func newTransmitter(c *cli.Context) *smpp.Transmitter {
tx := &smpp.Transmitter{
Addr: c.GlobalString("addr"),
User: os.Getenv("SMPP_USER"),
Passwd: os.Getenv("SMPP_PASSWD"),
}
if s := c.GlobalString("user"); s != "" {
tx.User = s
}
if s := c.GlobalString("passwd"); s != "" {
tx.Passwd = s
}
if c.GlobalBool("tls") {
host, _, _ := net.SplitHostPort(tx.Addr)
tx.TLS = &tls.Config{
ServerName: host,
}
if c.GlobalBool("precaire") {
tx.TLS.InsecureSkipVerify = true
}
}
conn := <-tx.Bind()
switch conn.Status() {
case smpp.Connected:
default:
log.Fatalln("Connection failed:", conn.Error())
}
return tx
}
示例8: createSubnetCommandFunc
func createSubnetCommandFunc(c *cli.Context) {
var subnet string
if len(c.Args()) == 0 {
log.Fatal("You need to specify a subnet")
} else {
subnet = c.Args()[0]
}
clnt := client.New(c.GlobalString("server"))
if c.GlobalBool("debug") {
clnt.SetDebug()
}
if c.Bool("prompt") {
s := client.Subnet{
Subnet: subnet,
// Calculate automatically based on subnet/prefix
Mask: prompt.String("Mask", prompt.Prompt{NoDefault: true, FuncPtr: validateIPv4, FuncInp: ""}),
// Default to .254 for subnet
Gw: prompt.String("Gateway", prompt.Prompt{NoDefault: true, FuncPtr: validateIPv4, FuncInp: ""}),
SiteID: *chooseSite(clnt, ""),
}
// Create subnet
clnt.Subnet.Create(&s)
return
}
}
示例9: cmdGet
func cmdGet(c *cli.Context) {
verbose = c.GlobalBool("verbose")
path := c.Args().Get(0)
key := c.String("key")
files := strings.Split(c.String("file"), ",")
envs := strings.Split(c.String("env"), ",")
if len(path) < 1 {
path = "." // default to current directory
}
if len(key) < 1 {
key = strings.ToLower(filepath.Base(files[0]))
}
hash := checksum(files, envs)
fullPath := filepath.Join(CachePath, strings.Join([]string{key, hash}, "-")) + ".tar.gz"
// get cache if exists
if _, err := os.Stat(fullPath); err == nil {
printInfo("Fetching cache '%s'. Please, wait...", key)
args := []string{
"-xzf",
fullPath,
"-C",
path,
}
err := exec.Command("tar", args...).Run()
checkError(err)
}
}
示例10: revelIndex
func revelIndex(ctx *cli.Context) {
template_dir, err := default_template_dir(ctx)
if err != nil {
fmt.Println(err.Error())
return
}
force := ctx.GlobalBool("force")
theme := ctx.String("theme")
if theme == "" {
fmt.Println("unknown template theme, please use -t to provide.")
return
}
args := ctx.Args()
if len(args) == 0 {
fmt.Println("Usage: scaffold revel index <project>")
return
}
if err := revel_index(args[0], template_dir, theme, force); err != nil {
fmt.Println("scaffold revel index <"+args[0]+"> failed:", err)
return
}
}
示例11: updateTagCommandFunc
func updateTagCommandFunc(c *cli.Context) {
if len(c.Args()) == 0 {
log.Fatal("You need to specify a tag")
}
tag := c.Args()[0]
clnt := client.New(c.GlobalString("server"))
if c.GlobalBool("debug") {
clnt.SetDebug()
}
v, err := clnt.Tag.Get(tag)
if err != nil {
log.Fatal(err.Error())
}
if c.Bool("prompt") {
s := client.Tag{
ID: v.ID,
Tag: prompt.String("Image", prompt.Prompt{Default: v.Tag, FuncPtr: prompt.Regex, FuncInp: ""}),
Created: prompt.String("Created", prompt.Prompt{Default: v.Created, FuncPtr: prompt.Regex, FuncInp: ""}),
SHA256: prompt.String("SHA256", prompt.Prompt{Default: v.SHA256, FuncPtr: prompt.Regex, FuncInp: "^[0-9a-f]+$"}),
ImageID: *chooseImage(clnt, v.ImageID),
}
// Update tag
clnt.Tag.Update(tag, &s)
return
}
}
示例12: MakeChain
// MakeChain creates a chain manager from set command line flags.
func MakeChain(ctx *cli.Context) (chain *core.BlockChain, chainDb ethdb.Database) {
datadir := MustMakeDataDir(ctx)
cache := ctx.GlobalInt(CacheFlag.Name)
handles := MakeDatabaseHandles()
var err error
if chainDb, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "chaindata"), cache, handles); err != nil {
Fatalf("Could not open database: %v", err)
}
if ctx.GlobalBool(OlympicFlag.Name) {
_, err := core.WriteTestNetGenesisBlock(chainDb)
if err != nil {
glog.Fatalln(err)
}
}
eventMux := new(event.TypeMux)
pow := ethash.New()
//genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB)
chain, err = core.NewBlockChain(chainDb, pow, eventMux)
if err != nil {
Fatalf("Could not start chainmanager: %v", err)
}
return chain, chainDb
}
示例13: runPing
func runPing(c *cli.Context) {
if c.GlobalBool("verbose") {
fmt.Println("Connetion to mikrotik...")
}
conf, err := getConfig(c)
assert(err)
// fmt.Printf("config: %#v", conf.Secret)
m := Routerboard{Config: &conf, Verbose: c.GlobalBool("verbose")}
// fmt.Printf("m.Config.Hosts: %v\n", m.Config.Hosts)
// debug(conf)
for i, h := range m.Config.Hosts {
err, code, res := m.RouterboardResource(h.Ip, h.Username, h.Passwd)
if err != nil {
// Unexpected result on login
// fmt.Printf("Error: %v\n", err.Error())
if code == 1 {
fmt.Printf("%v) Error no ping: %s [ %s ] %s (# %s)\n", i+1, h.Name, h.Ip, h.Adress, h.Dogovor)
} else if code == 2 {
fmt.Printf("%v) Error no connect: %s [ %s ] %s (# %s)\n", i+1, h.Name, h.Ip, h.Adress, h.Dogovor)
}
}
if m.Verbose && code == 200 {
fmt.Printf("%v) %s [ %s ] %s | cpu load %s\n", i+1, h.Name, h.Ip, h.Adress, res.CpuLoad)
}
}
// h := Host{Ip: '178.151.111.129', name: 'kievhleb032', adress: 'Харківське шосе, 144-б 2254709', ping: true, changefreq: 'weekly', priority: 1.0, username: 'admin', passwd: '1AzRss53' },
}
示例14: runShowFireWall
func runShowFireWall(c *cli.Context) {
conf, err := getConfig(c)
assert(err)
m := Routerboard{Config: &conf, Verbose: c.GlobalBool("verbose")}
err, _ = m.RouterboardInterface("178.151.111.129", "admin", "1AzRss53")
assert(err)
}
示例15: setupLogging
func setupLogging(c *cli.Context) error {
if c.GlobalBool("debug") {
log.SetLevel(log.DebugLevel)
log.Debug("Set loglevel to debug")
}
return nil
}