1 ![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png) |
1 ![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png) |
2 |
2 |
3 Cobra is a library for creating powerful modern CLI applications. |
3 Cobra is a library for creating powerful modern CLI applications. |
4 |
4 |
5 Cobra is used in many Go projects such as [Kubernetes](https://kubernetes.io/), |
5 Cobra is used in many Go projects such as [Kubernetes](https://kubernetes.io/), |
6 [Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to |
6 [Hugo](https://gohugo.io), and [GitHub CLI](https://github.com/cli/cli) to |
7 name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra. |
7 name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra. |
8 |
8 |
9 [![](https://img.shields.io/github/workflow/status/spf13/cobra/Test?longCache=tru&label=Test&logo=github%20actions&logoColor=fff)](https://github.com/spf13/cobra/actions?query=workflow%3ATest) |
9 [![](https://img.shields.io/github/workflow/status/spf13/cobra/Test?longCache=tru&label=Test&logo=github%20actions&logoColor=fff)](https://github.com/spf13/cobra/actions?query=workflow%3ATest) |
10 [![Go Reference](https://pkg.go.dev/badge/github.com/spf13/cobra.svg)](https://pkg.go.dev/github.com/spf13/cobra) |
10 [![Go Reference](https://pkg.go.dev/badge/github.com/spf13/cobra.svg)](https://pkg.go.dev/github.com/spf13/cobra) |
11 [![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra) |
11 [![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra) |
21 * Fully POSIX-compliant flags (including short & long versions) |
21 * Fully POSIX-compliant flags (including short & long versions) |
22 * Nested subcommands |
22 * Nested subcommands |
23 * Global, local and cascading flags |
23 * Global, local and cascading flags |
24 * Intelligent suggestions (`app srver`... did you mean `app server`?) |
24 * Intelligent suggestions (`app srver`... did you mean `app server`?) |
25 * Automatic help generation for commands and flags |
25 * Automatic help generation for commands and flags |
|
26 * Grouping help for subcommands |
26 * Automatic help flag recognition of `-h`, `--help`, etc. |
27 * Automatic help flag recognition of `-h`, `--help`, etc. |
27 * Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell) |
28 * Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell) |
28 * Automatically generated man pages for your application |
29 * Automatically generated man pages for your application |
29 * Command aliases so you can change things without breaking them |
30 * Command aliases so you can change things without breaking them |
30 * The flexibility to define your own help, usage, etc. |
31 * The flexibility to define your own help, usage, etc. |
38 |
39 |
39 The best applications read like sentences when used, and as a result, users |
40 The best applications read like sentences when used, and as a result, users |
40 intuitively know how to interact with them. |
41 intuitively know how to interact with them. |
41 |
42 |
42 The pattern to follow is |
43 The pattern to follow is |
43 `APPNAME VERB NOUN --ADJECTIVE.` |
44 `APPNAME VERB NOUN --ADJECTIVE` |
44 or |
45 or |
45 `APPNAME COMMAND ARG --FLAG` |
46 `APPNAME COMMAND ARG --FLAG`. |
46 |
47 |
47 A few good real world examples may better illustrate this point. |
48 A few good real world examples may better illustrate this point. |
48 |
49 |
49 In the following example, 'server' is a command, and 'port' is a flag: |
50 In the following example, 'server' is a command, and 'port' is a flag: |
50 |
51 |