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

Golang docopt-go.Parse函数代码示例

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

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



在下文中一共展示了Parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:laurrentt,项目名称:deis,代码行数:25,代码来源:perms.go


示例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)
}
开发者ID:CodeJuan,项目名称:deis,代码行数:25,代码来源:releases.go


示例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)
}
开发者ID:arschles,项目名称:deis-controller,代码行数:30,代码来源:tags.go


示例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
}
开发者ID:pombredanne,项目名称:deo,代码行数:32,代码来源:cmd.go


示例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)
}
开发者ID:CodeJuan,项目名称:deis,代码行数:27,代码来源:auth.go


示例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)
}
开发者ID:CodeJuan,项目名称:deis,代码行数:33,代码来源:perms.go


示例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
}
开发者ID:pombredanne,项目名称:deo,代码行数:35,代码来源:cmd.go


示例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)
}
开发者ID:laurrentt,项目名称:deis,代码行数:26,代码来源:apps.go


示例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)
}
开发者ID:laurrentt,项目名称:deis,代码行数:25,代码来源:apps.go


示例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))
}
开发者ID:laurrentt,项目名称:deis,代码行数:25,代码来源:config.go


示例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)
}
开发者ID:laurrentt,项目名称:deis,代码行数:35,代码来源:apps.go


示例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)
}
开发者ID:laurrentt,项目名称:deis,代码行数:30,代码来源:config.go


示例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()
}
开发者ID:tob1k,项目名称:deisctl,代码行数:26,代码来源:update.go


示例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))
}
开发者ID:CodeJuan,项目名称:deis,代码行数:26,代码来源:ps.go


示例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)
}
开发者ID:uniite,项目名称:deis,代码行数:29,代码来源:client.go


示例16: appCreate

func appCreate(argv []string) error {
	usage := `
Creates a new application.

- if no <id> is provided, one will be generated automatically.

Usage: deis apps:create [<id>] [options]

Arguments:
  <id>
    a uniquely identifiable name for the application. No other app can already
    exist with this name.

Options:
  --no-remote
    do not create a 'deis' git remote.
  -b --buildpack BUILDPACK
    a buildpack url to use for this app
  -r --remote REMOTE
    name of remote to create. [default: deis]
`
	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	id := safeGetValue(args, "<id>")
	buildpack := safeGetValue(args, "--buildpack")
	remote := safeGetValue(args, "--remote")
	noRemote := args["--no-remote"].(bool)

	return cmd.AppCreate(id, buildpack, remote, noRemote)
}
开发者ID:laurrentt,项目名称:deis,代码行数:34,代码来源:apps.go


示例17: Dock

func (c *Client) Dock(argv []string) error {
	usage := `Connect to the named docker container and run commands on it.

This is equivalent to running 'docker exec -it <target> <command>'.

Usage:
  deisctl dock <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.Dock(target, vargs, c.Backend)
}
开发者ID:uniite,项目名称:deis,代码行数:28,代码来源:client.go


示例18: certsList

func certsList(argv []string) error {
	usage := `
Show certificate information for an SSL application.

Usage: deis certs:list [options]

Options:
  -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
	}

	results, err := responseLimit(safeGetValue(args, "--limit"))

	if err != nil {
		return err
	}

	return cmd.CertsList(results)
}
开发者ID:CodeJuan,项目名称:deis,代码行数:25,代码来源:certs.go


示例19: permCreate

func permCreate(argv []string) error {
	usage := `
Gives another user permission to use an app, or gives another user
system administrator privileges.

Usage: deis perms:create <username> [-a --app=<app>|--admin]

Arguments:
  <username>
    the name of the new user.

Options:
  -a --app=<app>
    grants <username> permission to use <app>. <app> is the uniquely identifiable name
    for the application.
  --admin
    grants <username> system administrator privileges.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	app := safeGetValue(args, "--app")
	username := args["<username>"].(string)
	admin := args["--admin"].(bool)

	return cmd.PermCreate(app, username, admin)
}
开发者ID:CodeJuan,项目名称:deis,代码行数:31,代码来源:perms.go


示例20: certAdd

func certAdd(argv []string) error {
	usage := `
Binds a certificate/key pair to an application.

Usage: deis certs:add <cert> <key> [options]

Arguments:
  <cert>
    The public key of the SSL certificate.
  <key>
    The private key of the SSL certificate.

Options:
  --common-name=<cname>
    The common name of the certificate. If none is provided, the controller will
    interpret the common name from the certificate.
  --subject-alt-names=<sans>
    The subject alternate names (SAN) of the certificate, separated by commas. This will
    create multiple Certificate objects in the controller, one for each SAN.
`

	args, err := docopt.Parse(usage, argv, true, "", false, true)

	if err != nil {
		return err
	}

	cert := args["<cert>"].(string)
	key := args["<key>"].(string)
	commonName := safeGetValue(args, "--common-name")
	sans := safeGetValue(args, "--subject-alt-names")

	return cmd.CertAdd(cert, key, commonName, sans)
}
开发者ID:CodeJuan,项目名称:deis,代码行数:34,代码来源:certs.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang remote.Remote类代码示例发布时间:2022-05-23
下一篇:
Golang libcontainer.Config类代码示例发布时间: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