本文整理匯總了Golang中github.com/docopt/docopt-go.Parse函數的典型用法代碼示例。如果您正苦於以下問題:Golang Parse函數的具體用法?Golang Parse怎麽用?Golang Parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Parse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: permsList
func permsList(argv []string) error {
usage := `
Lists all users with permission to use an app, or lists all users with system
administrator privileges.
Usage: deis perms:list [-a --app=<app>|--admin]
Options:
-a --app=<app>
lists all users with permission to <app>. <app> is the uniquely identifiable name
for the application.
--admin
lists all users with system administrator privileges.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
admin := args["--admin"].(bool)
return cmd.PermsList(safeGetValue(args, "--app"), admin)
}
示例2: releasesInfo
func releasesInfo(argv []string) error {
usage := `
Prints info about a particular release.
Usage: deis releases:info <version> [options]
Arguments:
<version>
the release of the application, such as 'v1'.
Options:
-a --app=<app>
the uniquely identifiable name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
version, err := versionFromString(args["<version>"].(string))
if err != nil {
return err
}
return cmd.ReleasesInfo(safeGetValue(args, "--app"), version)
}
示例3: tagsSet
func tagsSet(argv []string) error {
usage := `
Sets tags for an application.
A tag is a key/value pair used to tag an application's containers and is passed to the
scheduler. This is often used to restrict workloads to specific hosts matching the
scheduler-configured metadata.
Usage: deis tags:set [options] <key>=<value>...
Arguments:
<key> the tag key, for example: "environ" or "rack"
<value> the tag value, for example: "prod" or "1"
Options:
-a --app=<app>
the uniquely identifiable name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
tags := args["<key>=<value>"].([]string)
return cmd.TagsSet(app, tags)
}
示例4: Start
// Start activates the specified components.
func Start(argv []string, b backend.Backend) error {
usage := `Activates the specified components.
Usage:
deisctl start [<target>...] [options]
`
// parse command-line arguments
args, err := docopt.Parse(usage, argv, true, "", false)
if err != nil {
return err
}
// if target is platform, install all services
targets := args["<target>"].([]string)
if len(targets) == 1 && targets[0] == PlatformCommand {
return StartPlatform(b)
}
outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
b.Start(targets, &wg, outchan, errchan)
wg.Wait()
close(outchan)
return nil
}
示例5: authCancel
func authCancel(argv []string) error {
usage := `
Cancels and removes the current account.
Usage: deis auth:cancel [options]
Options:
--username=<username>
provide a username for the account.
--password=<password>
provide a password for the account.
--yes
force "yes" when prompted.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
username := safeGetValue(args, "--username")
password := safeGetValue(args, "--password")
yes := args["--yes"].(bool)
return cmd.Cancel(username, password, yes)
}
示例6: permsList
func permsList(argv []string) error {
usage := `
Lists all users with permission to use an app, or lists all users with system
administrator privileges.
Usage: deis perms:list [-a --app=<app>|--admin|--admin --limit=<num>]
Options:
-a --app=<app>
lists all users with permission to <app>. <app> is the uniquely identifiable name
for the application.
--admin
lists all users with system administrator privileges.
-l --limit=<num>
the maximum number of results to display, defaults to config setting
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
admin := args["--admin"].(bool)
results, err := responseLimit(safeGetValue(args, "--limit"))
if err != nil {
return err
}
return cmd.PermsList(safeGetValue(args, "--app"), admin, results)
}
示例7: Uninstall
// Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called.
func Uninstall(argv []string, b backend.Backend) error {
usage := `Unloads the definitions of the specified components.
After uninstall, the components will be unavailable until install is called.
Usage:
deisctl uninstall [<target>...] [options]
`
// parse command-line arguments
args, err := docopt.Parse(usage, argv, true, "", false)
if err != nil {
return err
}
// if target is platform, uninstall all services
targets := args["<target>"].([]string)
if len(targets) == 1 && targets[0] == PlatformCommand {
return UninstallPlatform(b)
}
outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
// uninstall the specific target
b.Destroy(targets, &wg, outchan, errchan)
wg.Wait()
close(outchan)
return nil
}
示例8: appRun
func appRun(argv []string) error {
usage := `
Runs a command inside an ephemeral app container. Default environment is
/bin/bash.
Usage: deis apps:run [options] [--] <command>...
Arguments:
<command>
the shell command to run inside the container.
Options:
-a --app=<app>
the uniquely identifiable name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
command := strings.Join(args["<command>"].([]string), " ")
return cmd.AppRun(app, command)
}
示例9: appDestroy
func appDestroy(argv []string) error {
usage := `
Destroys an application.
Usage: deis apps:destroy [options]
Options:
-a --app=<app>
the uniquely identifiable name for the application.
--confirm=<app>
skips the prompt for the application name. <app> is the uniquely identifiable
name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
confirm := safeGetValue(args, "--confirm")
return cmd.AppDestroy(app, confirm)
}
示例10: configSet
func configSet(argv []string) error {
usage := `
Sets environment variables for an application.
Usage: deis config:set <var>=<value> [<var>=<value>...] [options]
Arguments:
<var>
the uniquely identifiable name for the environment variable.
<value>
the value of said environment variable.
Options:
-a --app=<app>
the uniquely identifiable name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
return cmd.ConfigSet(safeGetValue(args, "--app"), args["<var>=<value>"].([]string))
}
示例11: appLogs
func appLogs(argv []string) error {
usage := `
Retrieves the most recent log events.
Usage: deis apps:logs [options]
Options:
-a --app=<app>
the uniquely identifiable name for the application.
-n --lines=<lines>
the number of lines to display
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
linesStr := safeGetValue(args, "--lines")
var lines int
if linesStr == "" {
lines = -1
} else {
lines, err = strconv.Atoi(linesStr)
if err != nil {
return err
}
}
return cmd.AppLogs(app, lines)
}
示例12: configPull
func configPull(argv []string) error {
usage := `
Extract all environment variables from an application for local use.
Your environment will be stored locally in a file named .env. This file can be
read by foreman to load the local environment for your app.
Usage: deis config:pull [options]
Options:
-a --app=<app>
The application that you wish to pull from
-i --interactive
Prompts for each value to be overwritten
-o --overwrite
Allows you to have the pull overwrite keys in .env
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
interactive := args["--interactive"].(bool)
overwrite := args["--overwrite"].(bool)
return cmd.ConfigPull(app, interactive, overwrite)
}
示例13: Update
// Update runs the Deis update engine daemon
func Update() error {
usage := `Deis Update Daemon
Usage:
deisctl update [options]
Options:
--verbose print out the request bodies [default: false]
--min-sleep=<sec> minimum time between update checks [default: 10]
--max-sleep=<sec> maximum time between update checks [default: 30]
--server=<server> alternate update server URL (optional)
`
// parse command-line arguments
args, err := docopt.Parse(usage, nil, true, "", true)
if err != nil {
return err
}
fmt.Printf("args: %v\n", args)
err = setUpdateFlags(args)
if err != nil {
return err
}
fmt.Printf("flags: %v\n", Flags)
return doUpdate()
}
示例14: psScale
func psScale(argv []string) error {
usage := `
Scales an application's processes by type.
Usage: deis ps:scale <type>=<num>... [options]
Arguments:
<type>
the process name as defined in your Procfile, such as 'web' or 'worker'.
Note that Dockerfile apps have a default 'cmd' process type.
<num>
the number of processes.
Options:
-a --app=<app>
the uniquely identifiable name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
return cmd.PsScale(safeGetValue(args, "--app"), args["<type>=<num>"].([]string))
}
示例15: SSH
// SSH opens an interactive shell with a machine in the cluster.
func (c *Client) SSH(argv []string) error {
usage := `Open an interactive shell on a machine in the cluster given a unit or machine id.
If an optional <command> is provided, that command is run remotely, and the results returned.
Usage:
deisctl ssh <target> [<command>...]
`
// parse command-line arguments
args, err := docopt.Parse(usage, argv, true, "", true)
if err != nil {
return err
}
target := args["<target>"].(string)
// handle help explicitly since docopt parsing is relaxed
if target == "--help" {
fmt.Println(usage)
os.Exit(0)
}
var vargs []string
if v, ok := args["<command>"]; ok {
vargs = v.([]string)
}
return cmd.SSH(target, vargs, c.Backend)
}