summaryrefslogtreecommitdiff
path: root/vendor/github.com/urfave/cli/README.md
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2017-12-04 10:24:08 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-04 20:03:16 +0000
commit265efcb9f88a78ee52eb5644d4db86e49788991f (patch)
treecf0d95609547408a30bcad558829701b344fc787 /vendor/github.com/urfave/cli/README.md
parent750fc239b5da8e3f2792ae33f46a671ddf4622e3 (diff)
downloadpodman-265efcb9f88a78ee52eb5644d4db86e49788991f.tar.gz
podman-265efcb9f88a78ee52eb5644d4db86e49788991f.tar.bz2
podman-265efcb9f88a78ee52eb5644d4db86e49788991f.zip
Vendor in latest urfave/cli
The latest urfave/cli has the ability for us to use short options when it is a bool. Signed-off-by: baude <bbaude@redhat.com> Closes: #100 Approved by: rhatdan
Diffstat (limited to 'vendor/github.com/urfave/cli/README.md')
-rw-r--r--vendor/github.com/urfave/cli/README.md71
1 files changed, 69 insertions, 2 deletions
diff --git a/vendor/github.com/urfave/cli/README.md b/vendor/github.com/urfave/cli/README.md
index 2bbbd8ea9..6096701d8 100644
--- a/vendor/github.com/urfave/cli/README.md
+++ b/vendor/github.com/urfave/cli/README.md
@@ -32,7 +32,9 @@ applications in an expressive way.
+ [Alternate Names](#alternate-names)
+ [Ordering](#ordering)
+ [Values from the Environment](#values-from-the-environment)
+ + [Values from files](#values-from-files)
+ [Values from alternate input sources (YAML, TOML, and others)](#values-from-alternate-input-sources-yaml-toml-and-others)
+ + [Precedence](#precedence)
* [Subcommands](#subcommands)
* [Subcommands categories](#subcommands-categories)
* [Exit code](#exit-code)
@@ -45,6 +47,7 @@ applications in an expressive way.
* [Version Flag](#version-flag)
+ [Customization](#customization-2)
+ [Full API Example](#full-api-example)
+ * [Combining short Bool options](#combining-short-bool-options)
- [Contribution Guidelines](#contribution-guidelines)
<!-- tocstop -->
@@ -586,6 +589,41 @@ func main() {
}
```
+#### Values from files
+
+You can also have the default value set from file via `FilePath`. e.g.
+
+<!-- {
+ "args": ["&#45;&#45;help"],
+ "output": "password for the mysql database"
+} -->
+``` go
+package main
+
+import (
+ "os"
+
+ "github.com/urfave/cli"
+)
+
+func main() {
+ app := cli.NewApp()
+
+ app.Flags = []cli.Flag {
+ cli.StringFlag{
+ Name: "password, p",
+ Usage: "password for the mysql database",
+ FilePath: "/etc/mysql/password",
+ },
+ }
+
+ app.Run(os.Args)
+}
+```
+
+Note that default values set from file (e.g. `FilePath`) take precedence over
+default values set from the enviornment (e.g. `EnvVar`).
+
#### Values from alternate input sources (YAML, TOML, and others)
There is a separate package altsrc that adds support for getting flag values
@@ -656,6 +694,15 @@ func main() {
}
```
+#### Precedence
+
+The precedence for flag value sources is as follows (highest to lowest):
+
+0. Command line flag value from user
+0. Environment variable (if specified)
+0. Configuration file (if specified)
+0. Default defined on the flag
+
### Subcommands
Subcommands can be defined for a more git-like command line app.
@@ -751,11 +798,11 @@ func main() {
},
{
Name: "add",
- Category: "template",
+ Category: "Template actions",
},
{
Name: "remove",
- Category: "template",
+ Category: "Template actions",
},
}
@@ -1364,6 +1411,26 @@ func wopAction(c *cli.Context) error {
}
```
+### Combining short Bool options
+
+Traditional use of boolean options using their shortnames look like this:
+```
+# cmd foobar -s -o
+```
+
+Suppose you want users to be able to combine your bool options with their shortname. This
+can be done using the **UseShortOptionHandling** bool in your commands. Suppose your program
+has a two bool flags such as *serve* and *option* with the short options of *-o* and
+*-s* respectively. With **UseShortOptionHandling** set to *true*, a user can use a syntax
+like:
+```
+# cmd foobar -so
+```
+
+If you enable the **UseShortOptionHandling*, then you must not use any flags that have a single
+leading *-* or this will result in failures. For example, **-option** can no longer be used. Flags
+with two leading dashes (such as **--options**) are still valid.
+
## Contribution Guidelines
Feel free to put up a pull request to fix a bug or maybe add a feature. I will