本文整理汇总了Golang中github.com/urfave/cli.Context.StringSlice方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.StringSlice方法的具体用法?Golang Context.StringSlice怎么用?Golang Context.StringSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/urfave/cli.Context
的用法示例。
在下文中一共展示了Context.StringSlice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: userGrantRevoke
func userGrantRevoke(c *cli.Context, grant bool) {
roles := c.StringSlice("roles")
if len(roles) == 0 {
fmt.Fprintln(os.Stderr, "No roles specified; please use `--roles`")
os.Exit(1)
}
ctx, cancel := contextWithTotalTimeout(c)
defer cancel()
api, user := mustUserAPIAndName(c)
currentUser, err := api.GetUser(ctx, user)
if currentUser == nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
if grant {
_, err = api.GrantUser(ctx, user, roles)
} else {
_, err = api.RevokeUser(ctx, user, roles)
}
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
fmt.Printf("User %s updated\n", user)
}
示例2: runTemplate
func runTemplate(c *cli.Context) error {
data := NewData(c.StringSlice("datasource"))
g := NewGomplate(data)
g.RunTemplate(os.Stdin, os.Stdout)
return nil
}
示例3: before
func before(c *cli.Context) error {
// Log level
if logLevel, err := log.ParseLevel(c.String(LogLevelKey)); err != nil {
log.Fatal("Failed to parse log level:", err)
} else {
log.SetLevel(logLevel)
}
if len(c.Args()) != 0 && c.Args().First() != "version" && !c.Bool(HelpKey) && !c.Bool(VersionKey) {
if err := MachineWorkdir.Set(c.String(WorkdirKey)); err != nil {
log.Fatalf("Failed to set MachineWorkdir: %s", err)
}
if MachineWorkdir.String() == "" {
log.Fatalln("No Workdir specified!")
}
}
MachineWorkdir.Freeze()
if err := MachineConfigTypeID.Set(c.String(ConfigTypeIDParamKey)); err != nil {
log.Fatalf("Failed to set MachineConfigTypeID: %s", err)
}
log.Debugf("MachineConfigTypeID: %s", MachineConfigTypeID)
if err := MachineParamsAdditionalEnvs.Set(c.StringSlice(EnvironmentParamKey)); err != nil {
log.Fatalf("Failed to set MachineParamsAdditionalEnvs: %s", err)
}
log.Debugf("MachineParamsAdditionalEnvs: %s", MachineParamsAdditionalEnvs)
MachineParamsAdditionalEnvs.Freeze()
return nil
}
示例4: run
func run(c *cli.Context) error {
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
plugin := Plugin{
Repo: Repo{
Owner: c.String("repo.owner"),
Name: c.String("repo.name"),
},
Build: Build{
Event: c.String("build.event"),
},
Commit: Commit{
Ref: c.String("commit.ref"),
},
Config: Config{
APIKey: c.String("api-key"),
Files: c.StringSlice("files"),
FileExists: c.String("file-exists"),
Checksum: c.StringSlice("checksum"),
Draft: c.Bool("draft"),
BaseURL: c.String("base-url"),
UploadURL: c.String("upload-url"),
},
}
return plugin.Exec()
}
示例5: Run
func (cmd *Restart) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
parms := c.StringSlice("param")
invoke(cmd.network, scope.Application, scope.Entity, restartEffector, parms)
}
示例6: run
func run(c *cli.Context) error {
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
plugin := Plugin{
Repo: Repo{
Owner: c.String("repo.owner"),
Name: c.String("repo.name"),
},
Commit: Commit{
Sha: c.String("commit.sha"),
Ref: c.String("commit.ref"),
Branch: c.String("commit.branch"),
Author: c.String("commit.author"),
Link: c.String("commit.link"),
},
Build: Build{
Number: c.Int("build.number"),
Event: c.String("build.event"),
Status: c.String("build.status"),
Deploy: c.String("build.deploy"),
Link: c.String("build.link"),
},
Config: Config{
Webhook: c.StringSlice("webhook"),
},
}
return plugin.Exec()
}
示例7: run
func run(c *cli.Context) error {
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
plugin := Plugin{
Repo: Repo{
FullName: c.String("repo.fullname"),
Owner: c.String("repo.owner"),
Name: c.String("repo.name"),
Link: c.String("repo.link"),
},
Build: Build{
Commit: c.String("commit.sha"),
Branch: c.String("commit.branch"),
Ref: c.String("commit.ref"),
Link: c.String("commit.link"),
Message: c.String("commit.message"),
Author: c.String("commit.author.name"),
Email: c.String("commit.author.email"),
Number: c.Int("build.number"),
Status: c.String("build.status"),
Event: c.String("build.event"),
Deploy: c.String("build.deploy"),
BuildLink: c.String("build.link"),
},
BuildLast: Build{
Number: c.Int("prev.build.number"),
Status: c.String("prev.build.status"),
Commit: c.String("prev.commit.sha"),
},
Config: Config{
Token: c.String("token"),
Channel: c.String("channel"),
Mapping: c.String("mapping"),
Success: MessageOptions{
Username: c.String("success_username"),
Icon: c.String("success_icon"),
Template: c.String("success_template"),
ImageAttachments: c.StringSlice("success_image_attachments"),
},
Failure: MessageOptions{
Username: c.String("failure_username"),
Icon: c.String("failure_icon"),
Template: c.String("failure_template"),
ImageAttachments: c.StringSlice("failure_image_attachments"),
},
},
}
return plugin.Exec()
}
示例8: run
func run(c *cli.Context) error {
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
plugin := Plugin{
Repos: c.StringSlice("repositories"),
Server: c.String("server"),
Token: c.String("token"),
Fork: c.Bool("fork"),
}
return plugin.Exec()
}
示例9: setEmptyNsMask
func setEmptyNsMask(context *cli.Context, options *libcontainer.CriuOpts) error {
var nsmask int
for _, ns := range context.StringSlice("empty-ns") {
f, exists := namespaceMapping[specs.NamespaceType(ns)]
if !exists {
return fmt.Errorf("namespace %q is not supported", ns)
}
nsmask |= f
}
options.EmptyNs = uint32(nsmask)
return nil
}
示例10: getDiscoveryOpt
func getDiscoveryOpt(c *cli.Context) map[string]string {
// Process the store options
options := map[string]string{}
for _, option := range c.StringSlice("discovery-opt") {
if !strings.Contains(option, "=") {
log.Fatal("--discovery-opt must contain key=value strings")
}
kvpair := strings.SplitN(option, "=", 2)
options[kvpair[0]] = kvpair[1]
}
if _, ok := options["kv.path"]; !ok {
options["kv.path"] = "docker/swarm/nodes"
}
return options
}
示例11: doMain
// main function
func doMain(c *cli.Context) error {
var apache2 Apache2Plugin
apache2.Host = c.String("http_host")
apache2.Port = uint16(c.Int("http_port"))
apache2.Path = c.String("status_page")
apache2.Header = c.StringSlice("header")
helper := mp.NewMackerelPlugin(apache2)
helper.Tempfile = c.String("tempfile")
helper.Run()
return nil
}
示例12: Run
func (cmd *Entity) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
cmd.listentity(scope.Application, c.StringSlice("children")[0])
} else {
if c.Args().Present() {
cmd.show(scope.Application, c.Args().First())
} else {
if scope.Entity == scope.Application {
cmd.listapp(scope.Application)
} else {
cmd.listentity(scope.Application, scope.Entity)
}
}
}
}
示例13: run
func run(c *cli.Context) error {
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
plugin := Plugin{
Config: Config{
Key: c.String("ssh-key"),
User: c.String("user"),
Host: c.StringSlice("host"),
Port: c.Int("port"),
Sleep: c.Int("sleep"),
Timeout: c.Duration("timeout"),
Script: c.StringSlice("script"),
},
}
return plugin.Exec()
}
示例14: run
func run(c *cli.Context) error {
logrus.WithFields(logrus.Fields{
"Revision": revision,
}).Info("Drone Terraform Plugin Version")
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
remote := Remote{}
json.Unmarshal([]byte(c.String("remote")), &remote)
var vars map[string]string
if c.String("vars") != "" {
if err := json.Unmarshal([]byte(c.String("vars")), &vars); err != nil {
panic(err)
}
}
var secrets map[string]string
if c.String("secrets") != "" {
if err := json.Unmarshal([]byte(c.String("secrets")), &secrets); err != nil {
panic(err)
}
}
plugin := Plugin{
Config: Config{
Remote: remote,
Plan: c.Bool("plan"),
Vars: vars,
Secrets: secrets,
Cacert: c.String("ca_cert"),
Sensitive: c.Bool("sensitive"),
RoleARN: c.String("role_arn_to_assume"),
RootDir: c.String("root_dir"),
Parallelism: c.Int("parallelism"),
Targets: c.StringSlice("targets"),
},
}
return plugin.Exec()
}
示例15: doMain
// main function
func doMain(c *cli.Context) error {
var linux LinuxPlugin
typemap := map[string]bool{}
types := c.StringSlice("type")
// If no `type` is specified, fetch all metrics
if len(types) == 0 {
typemap["all"] = true
} else {
for _, t := range types {
typemap[t] = true
}
}
linux.Typemap = typemap
helper := mp.NewMackerelPlugin(linux)
helper.Tempfile = c.String("tempfile")
helper.Run()
return nil
}