README.md

  1![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png)
  2
  3Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.
  4
  5Many of the most widely used Go projects are built using Cobra, such as:
  6[Kubernetes](http://kubernetes.io/),
  7[Hugo](http://gohugo.io),
  8[rkt](https://github.com/coreos/rkt),
  9[etcd](https://github.com/coreos/etcd),
 10[Moby (former Docker)](https://github.com/moby/moby),
 11[Docker (distribution)](https://github.com/docker/distribution),
 12[OpenShift](https://www.openshift.com/),
 13[Delve](https://github.com/derekparker/delve),
 14[GopherJS](http://www.gopherjs.org/),
 15[CockroachDB](http://www.cockroachlabs.com/),
 16[Bleve](http://www.blevesearch.com/),
 17[ProjectAtomic (enterprise)](http://www.projectatomic.io/),
 18[Giant Swarm's gsctl](https://github.com/giantswarm/gsctl),
 19[Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack),
 20[rclone](http://rclone.org/),
 21[nehm](https://github.com/bogem/nehm),
 22[Pouch](https://github.com/alibaba/pouch),
 23[Istio](https://istio.io),
 24[Prototool](https://github.com/uber/prototool),
 25[mattermost-server](https://github.com/mattermost/mattermost-server),
 26[Gardener](https://github.com/gardener/gardenctl),
 27etc.
 28
 29[![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra)
 30[![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra)
 31[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra)
 32
 33# Table of Contents
 34
 35- [Overview](#overview)
 36- [Concepts](#concepts)
 37  * [Commands](#commands)
 38  * [Flags](#flags)
 39- [Installing](#installing)
 40- [Getting Started](#getting-started)
 41  * [Using the Cobra Generator](#using-the-cobra-generator)
 42  * [Using the Cobra Library](#using-the-cobra-library)
 43  * [Working with Flags](#working-with-flags)
 44  * [Positional and Custom Arguments](#positional-and-custom-arguments)
 45  * [Example](#example)
 46  * [Help Command](#help-command)
 47  * [Usage Message](#usage-message)
 48  * [PreRun and PostRun Hooks](#prerun-and-postrun-hooks)
 49  * [Suggestions when "unknown command" happens](#suggestions-when-unknown-command-happens)
 50  * [Generating documentation for your command](#generating-documentation-for-your-command)
 51  * [Generating bash completions](#generating-bash-completions)
 52  * [Generating zsh completions](#generating-zsh-completions)
 53- [Contributing](#contributing)
 54- [License](#license)
 55
 56# Overview
 57
 58Cobra is a library providing a simple interface to create powerful modern CLI
 59interfaces similar to git & go tools.
 60
 61Cobra is also an application that will generate your application scaffolding to rapidly
 62develop a Cobra-based application.
 63
 64Cobra provides:
 65* Easy subcommand-based CLIs: `app server`, `app fetch`, etc.
 66* Fully POSIX-compliant flags (including short & long versions)
 67* Nested subcommands
 68* Global, local and cascading flags
 69* Easy generation of applications & commands with `cobra init appname` & `cobra add cmdname`
 70* Intelligent suggestions (`app srver`... did you mean `app server`?)
 71* Automatic help generation for commands and flags
 72* Automatic help flag recognition of `-h`, `--help`, etc.
 73* Automatically generated bash autocomplete for your application
 74* Automatically generated man pages for your application
 75* Command aliases so you can change things without breaking them
 76* The flexibility to define your own help, usage, etc.
 77* Optional tight integration with [viper](http://github.com/spf13/viper) for 12-factor apps
 78
 79# Concepts
 80
 81Cobra is built on a structure of commands, arguments & flags.
 82
 83**Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions.
 84
 85The best applications will read like sentences when used. Users will know how
 86to use the application because they will natively understand how to use it.
 87
 88The pattern to follow is
 89`APPNAME VERB NOUN --ADJECTIVE.`
 90    or
 91`APPNAME COMMAND ARG --FLAG`
 92
 93A few good real world examples may better illustrate this point.
 94
 95In the following example, 'server' is a command, and 'port' is a flag:
 96
 97    hugo server --port=1313
 98
 99In this command we are telling Git to clone the url bare.
100
101    git clone URL --bare
102
103## Commands
104
105Command is the central point of the application. Each interaction that
106the application supports will be contained in a Command. A command can
107have children commands and optionally run an action.
108
109In the example above, 'server' is the command.
110
111[More about cobra.Command](https://godoc.org/github.com/spf13/cobra#Command)
112
113## Flags
114
115A flag is a way to modify the behavior of a command. Cobra supports
116fully POSIX-compliant flags as well as the Go [flag package](https://golang.org/pkg/flag/).
117A Cobra command can define flags that persist through to children commands
118and flags that are only available to that command.
119
120In the example above, 'port' is the flag.
121
122Flag functionality is provided by the [pflag
123library](https://github.com/spf13/pflag), a fork of the flag standard library
124which maintains the same interface while adding POSIX compliance.
125
126# Installing
127Using Cobra is easy. First, use `go get` to install the latest version
128of the library. This command will install the `cobra` generator executable
129along with the library and its dependencies:
130
131    go get -u github.com/spf13/cobra/cobra
132
133Next, include Cobra in your application:
134
135```go
136import "github.com/spf13/cobra"
137```
138
139# Getting Started
140
141While you are welcome to provide your own organization, typically a Cobra-based
142application will follow the following organizational structure:
143
144```
145  ▾ appName/
146    ▾ cmd/
147        add.go
148        your.go
149        commands.go
150        here.go
151      main.go
152```
153
154In a Cobra app, typically the main.go file is very bare. It serves one purpose: initializing Cobra.
155
156```go
157package main
158
159import (
160  "{pathToYourApp}/cmd"
161)
162
163func main() {
164  cmd.Execute()
165}
166```
167
168## Using the Cobra Generator
169
170Cobra provides its own program that will create your application and add any
171commands you want. It's the easiest way to incorporate Cobra into your application.
172
173[Here](https://github.com/spf13/cobra/blob/master/cobra/README.md) you can find more information about it.
174
175## Using the Cobra Library
176
177To manually implement Cobra you need to create a bare main.go file and a rootCmd file.
178You will optionally provide additional commands as you see fit.
179
180### Create rootCmd
181
182Cobra doesn't require any special constructors. Simply create your commands.
183
184Ideally you place this in app/cmd/root.go:
185
186```go
187var rootCmd = &cobra.Command{
188  Use:   "hugo",
189  Short: "Hugo is a very fast static site generator",
190  Long: `A Fast and Flexible Static Site Generator built with
191                love by spf13 and friends in Go.
192                Complete documentation is available at http://hugo.spf13.com`,
193  Run: func(cmd *cobra.Command, args []string) {
194    // Do Stuff Here
195  },
196}
197
198func Execute() {
199  if err := rootCmd.Execute(); err != nil {
200    fmt.Println(err)
201    os.Exit(1)
202  }
203}
204```
205
206You will additionally define flags and handle configuration in your init() function.
207
208For example cmd/root.go:
209
210```go
211import (
212  "fmt"
213  "os"
214
215  homedir "github.com/mitchellh/go-homedir"
216  "github.com/spf13/cobra"
217  "github.com/spf13/viper"
218)
219
220func init() {
221  cobra.OnInitialize(initConfig)
222  rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
223  rootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "", "base project directory eg. github.com/spf13/")
224  rootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
225  rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `licensetext` in config)")
226  rootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
227  viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
228  viper.BindPFlag("projectbase", rootCmd.PersistentFlags().Lookup("projectbase"))
229  viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))
230  viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
231  viper.SetDefault("license", "apache")
232}
233
234func initConfig() {
235  // Don't forget to read config either from cfgFile or from home directory!
236  if cfgFile != "" {
237    // Use config file from the flag.
238    viper.SetConfigFile(cfgFile)
239  } else {
240    // Find home directory.
241    home, err := homedir.Dir()
242    if err != nil {
243      fmt.Println(err)
244      os.Exit(1)
245    }
246
247    // Search config in home directory with name ".cobra" (without extension).
248    viper.AddConfigPath(home)
249    viper.SetConfigName(".cobra")
250  }
251
252  if err := viper.ReadInConfig(); err != nil {
253    fmt.Println("Can't read config:", err)
254    os.Exit(1)
255  }
256}
257```
258
259### Create your main.go
260
261With the root command you need to have your main function execute it.
262Execute should be run on the root for clarity, though it can be called on any command.
263
264In a Cobra app, typically the main.go file is very bare. It serves, one purpose, to initialize Cobra.
265
266```go
267package main
268
269import (
270  "{pathToYourApp}/cmd"
271)
272
273func main() {
274  cmd.Execute()
275}
276```
277
278### Create additional commands
279
280Additional commands can be defined and typically are each given their own file
281inside of the cmd/ directory.
282
283If you wanted to create a version command you would create cmd/version.go and
284populate it with the following:
285
286```go
287package cmd
288
289import (
290  "fmt"
291
292  "github.com/spf13/cobra"
293)
294
295func init() {
296  rootCmd.AddCommand(versionCmd)
297}
298
299var versionCmd = &cobra.Command{
300  Use:   "version",
301  Short: "Print the version number of Hugo",
302  Long:  `All software has versions. This is Hugo's`,
303  Run: func(cmd *cobra.Command, args []string) {
304    fmt.Println("Hugo Static Site Generator v0.9 -- HEAD")
305  },
306}
307```
308
309## Working with Flags
310
311Flags provide modifiers to control how the action command operates.
312
313### Assign flags to a command
314
315Since the flags are defined and used in different locations, we need to
316define a variable outside with the correct scope to assign the flag to
317work with.
318
319```go
320var Verbose bool
321var Source string
322```
323
324There are two different approaches to assign a flag.
325
326### Persistent Flags
327
328A flag can be 'persistent' meaning that this flag will be available to the
329command it's assigned to as well as every command under that command. For
330global flags, assign a flag as a persistent flag on the root.
331
332```go
333rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
334```
335
336### Local Flags
337
338A flag can also be assigned locally which will only apply to that specific command.
339
340```go
341localCmd.Flags().StringVarP(&Source, "source", "s", "", "Source directory to read from")
342```
343
344### Local Flag on Parent Commands
345
346By default Cobra only parses local flags on the target command, any local flags on
347parent commands are ignored. By enabling `Command.TraverseChildren` Cobra will
348parse local flags on each command before executing the target command.
349
350```go
351command := cobra.Command{
352  Use: "print [OPTIONS] [COMMANDS]",
353  TraverseChildren: true,
354}
355```
356
357### Bind Flags with Config
358
359You can also bind your flags with [viper](https://github.com/spf13/viper):
360```go
361var author string
362
363func init() {
364  rootCmd.PersistentFlags().StringVar(&author, "author", "YOUR NAME", "Author name for copyright attribution")
365  viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
366}
367```
368
369In this example the persistent flag `author` is bound with `viper`.
370**Note**, that the variable `author` will not be set to the value from config,
371when the `--author` flag is not provided by user.
372
373More in [viper documentation](https://github.com/spf13/viper#working-with-flags).
374
375### Required flags
376
377Flags are optional by default. If instead you wish your command to report an error
378when a flag has not been set, mark it as required:
379```go
380rootCmd.Flags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
381rootCmd.MarkFlagRequired("region")
382```
383
384## Positional and Custom Arguments
385
386Validation of positional arguments can be specified using the `Args` field
387of `Command`.
388
389The following validators are built in:
390
391- `NoArgs` - the command will report an error if there are any positional args.
392- `ArbitraryArgs` - the command will accept any args.
393- `OnlyValidArgs` - the command will report an error if there are any positional args that are not in the `ValidArgs` field of `Command`.
394- `MinimumNArgs(int)` - the command will report an error if there are not at least N positional args.
395- `MaximumNArgs(int)` - the command will report an error if there are more than N positional args.
396- `ExactArgs(int)` - the command will report an error if there are not exactly N positional args.
397- `ExactValidArgs(int)` - the command will report an error if there are not exactly N positional args OR if there are any positional args that are not in the `ValidArgs` field of `Command`
398- `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args.
399
400An example of setting the custom validator:
401
402```go
403var cmd = &cobra.Command{
404  Short: "hello",
405  Args: func(cmd *cobra.Command, args []string) error {
406    if len(args) < 1 {
407      return errors.New("requires a color argument")
408    }
409    if myapp.IsValidColor(args[0]) {
410      return nil
411    }
412    return fmt.Errorf("invalid color specified: %s", args[0])
413  },
414  Run: func(cmd *cobra.Command, args []string) {
415    fmt.Println("Hello, World!")
416  },
417}
418```
419
420## Example
421
422In the example below, we have defined three commands. Two are at the top level
423and one (cmdTimes) is a child of one of the top commands. In this case the root
424is not executable meaning that a subcommand is required. This is accomplished
425by not providing a 'Run' for the 'rootCmd'.
426
427We have only defined one flag for a single command.
428
429More documentation about flags is available at https://github.com/spf13/pflag
430
431```go
432package main
433
434import (
435  "fmt"
436  "strings"
437
438  "github.com/spf13/cobra"
439)
440
441func main() {
442  var echoTimes int
443
444  var cmdPrint = &cobra.Command{
445    Use:   "print [string to print]",
446    Short: "Print anything to the screen",
447    Long: `print is for printing anything back to the screen.
448For many years people have printed back to the screen.`,
449    Args: cobra.MinimumNArgs(1),
450    Run: func(cmd *cobra.Command, args []string) {
451      fmt.Println("Print: " + strings.Join(args, " "))
452    },
453  }
454
455  var cmdEcho = &cobra.Command{
456    Use:   "echo [string to echo]",
457    Short: "Echo anything to the screen",
458    Long: `echo is for echoing anything back.
459Echo works a lot like print, except it has a child command.`,
460    Args: cobra.MinimumNArgs(1),
461    Run: func(cmd *cobra.Command, args []string) {
462      fmt.Println("Print: " + strings.Join(args, " "))
463    },
464  }
465
466  var cmdTimes = &cobra.Command{
467    Use:   "times [string to echo]",
468    Short: "Echo anything to the screen more times",
469    Long: `echo things multiple times back to the user by providing
470a count and a string.`,
471    Args: cobra.MinimumNArgs(1),
472    Run: func(cmd *cobra.Command, args []string) {
473      for i := 0; i < echoTimes; i++ {
474        fmt.Println("Echo: " + strings.Join(args, " "))
475      }
476    },
477  }
478
479  cmdTimes.Flags().IntVarP(&echoTimes, "times", "t", 1, "times to echo the input")
480
481  var rootCmd = &cobra.Command{Use: "app"}
482  rootCmd.AddCommand(cmdPrint, cmdEcho)
483  cmdEcho.AddCommand(cmdTimes)
484  rootCmd.Execute()
485}
486```
487
488For a more complete example of a larger application, please checkout [Hugo](http://gohugo.io/).
489
490## Help Command
491
492Cobra automatically adds a help command to your application when you have subcommands.
493This will be called when a user runs 'app help'. Additionally, help will also
494support all other commands as input. Say, for instance, you have a command called
495'create' without any additional configuration; Cobra will work when 'app help
496create' is called.  Every command will automatically have the '--help' flag added.
497
498### Example
499
500The following output is automatically generated by Cobra. Nothing beyond the
501command and flag definitions are needed.
502
503    $ cobra help
504
505    Cobra is a CLI library for Go that empowers applications.
506    This application is a tool to generate the needed files
507    to quickly create a Cobra application.
508
509    Usage:
510      cobra [command]
511
512    Available Commands:
513      add         Add a command to a Cobra Application
514      help        Help about any command
515      init        Initialize a Cobra Application
516
517    Flags:
518      -a, --author string    author name for copyright attribution (default "YOUR NAME")
519          --config string    config file (default is $HOME/.cobra.yaml)
520      -h, --help             help for cobra
521      -l, --license string   name of license for the project
522          --viper            use Viper for configuration (default true)
523
524    Use "cobra [command] --help" for more information about a command.
525
526
527Help is just a command like any other. There is no special logic or behavior
528around it. In fact, you can provide your own if you want.
529
530### Defining your own help
531
532You can provide your own Help command or your own template for the default command to use
533with following functions:
534
535```go
536cmd.SetHelpCommand(cmd *Command)
537cmd.SetHelpFunc(f func(*Command, []string))
538cmd.SetHelpTemplate(s string)
539```
540
541The latter two will also apply to any children commands.
542
543## Usage Message
544
545When the user provides an invalid flag or invalid command, Cobra responds by
546showing the user the 'usage'.
547
548### Example
549You may recognize this from the help above. That's because the default help
550embeds the usage as part of its output.
551
552    $ cobra --invalid
553    Error: unknown flag: --invalid
554    Usage:
555      cobra [command]
556
557    Available Commands:
558      add         Add a command to a Cobra Application
559      help        Help about any command
560      init        Initialize a Cobra Application
561
562    Flags:
563      -a, --author string    author name for copyright attribution (default "YOUR NAME")
564          --config string    config file (default is $HOME/.cobra.yaml)
565      -h, --help             help for cobra
566      -l, --license string   name of license for the project
567          --viper            use Viper for configuration (default true)
568
569    Use "cobra [command] --help" for more information about a command.
570
571### Defining your own usage
572You can provide your own usage function or template for Cobra to use.
573Like help, the function and template are overridable through public methods:
574
575```go
576cmd.SetUsageFunc(f func(*Command) error)
577cmd.SetUsageTemplate(s string)
578```
579
580## Version Flag
581
582Cobra adds a top-level '--version' flag if the Version field is set on the root command.
583Running an application with the '--version' flag will print the version to stdout using
584the version template. The template can be customized using the
585`cmd.SetVersionTemplate(s string)` function.
586
587## PreRun and PostRun Hooks
588
589It is possible to run functions before or after the main `Run` function of your command. The `PersistentPreRun` and `PreRun` functions will be executed before `Run`. `PersistentPostRun` and `PostRun` will be executed after `Run`.  The `Persistent*Run` functions will be inherited by children if they do not declare their own.  These functions are run in the following order:
590
591- `PersistentPreRun`
592- `PreRun`
593- `Run`
594- `PostRun`
595- `PersistentPostRun`
596
597An example of two commands which use all of these features is below.  When the subcommand is executed, it will run the root command's `PersistentPreRun` but not the root command's `PersistentPostRun`:
598
599```go
600package main
601
602import (
603  "fmt"
604
605  "github.com/spf13/cobra"
606)
607
608func main() {
609
610  var rootCmd = &cobra.Command{
611    Use:   "root [sub]",
612    Short: "My root command",
613    PersistentPreRun: func(cmd *cobra.Command, args []string) {
614      fmt.Printf("Inside rootCmd PersistentPreRun with args: %v\n", args)
615    },
616    PreRun: func(cmd *cobra.Command, args []string) {
617      fmt.Printf("Inside rootCmd PreRun with args: %v\n", args)
618    },
619    Run: func(cmd *cobra.Command, args []string) {
620      fmt.Printf("Inside rootCmd Run with args: %v\n", args)
621    },
622    PostRun: func(cmd *cobra.Command, args []string) {
623      fmt.Printf("Inside rootCmd PostRun with args: %v\n", args)
624    },
625    PersistentPostRun: func(cmd *cobra.Command, args []string) {
626      fmt.Printf("Inside rootCmd PersistentPostRun with args: %v\n", args)
627    },
628  }
629
630  var subCmd = &cobra.Command{
631    Use:   "sub [no options!]",
632    Short: "My subcommand",
633    PreRun: func(cmd *cobra.Command, args []string) {
634      fmt.Printf("Inside subCmd PreRun with args: %v\n", args)
635    },
636    Run: func(cmd *cobra.Command, args []string) {
637      fmt.Printf("Inside subCmd Run with args: %v\n", args)
638    },
639    PostRun: func(cmd *cobra.Command, args []string) {
640      fmt.Printf("Inside subCmd PostRun with args: %v\n", args)
641    },
642    PersistentPostRun: func(cmd *cobra.Command, args []string) {
643      fmt.Printf("Inside subCmd PersistentPostRun with args: %v\n", args)
644    },
645  }
646
647  rootCmd.AddCommand(subCmd)
648
649  rootCmd.SetArgs([]string{""})
650  rootCmd.Execute()
651  fmt.Println()
652  rootCmd.SetArgs([]string{"sub", "arg1", "arg2"})
653  rootCmd.Execute()
654}
655```
656
657Output:
658```
659Inside rootCmd PersistentPreRun with args: []
660Inside rootCmd PreRun with args: []
661Inside rootCmd Run with args: []
662Inside rootCmd PostRun with args: []
663Inside rootCmd PersistentPostRun with args: []
664
665Inside rootCmd PersistentPreRun with args: [arg1 arg2]
666Inside subCmd PreRun with args: [arg1 arg2]
667Inside subCmd Run with args: [arg1 arg2]
668Inside subCmd PostRun with args: [arg1 arg2]
669Inside subCmd PersistentPostRun with args: [arg1 arg2]
670```
671
672## Suggestions when "unknown command" happens
673
674Cobra will print automatic suggestions when "unknown command" errors happen. This allows Cobra to behave similarly to the `git` command when a typo happens. For example:
675
676```
677$ hugo srever
678Error: unknown command "srever" for "hugo"
679
680Did you mean this?
681        server
682
683Run 'hugo --help' for usage.
684```
685
686Suggestions are automatic based on every subcommand registered and use an implementation of [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion.
687
688If you need to disable suggestions or tweak the string distance in your command, use:
689
690```go
691command.DisableSuggestions = true
692```
693
694or
695
696```go
697command.SuggestionsMinimumDistance = 1
698```
699
700You can also explicitly set names for which a given command will be suggested using the `SuggestFor` attribute. This allows suggestions for strings that are not close in terms of string distance, but makes sense in your set of commands and for some which you don't want aliases. Example:
701
702```
703$ kubectl remove
704Error: unknown command "remove" for "kubectl"
705
706Did you mean this?
707        delete
708
709Run 'kubectl help' for usage.
710```
711
712## Generating documentation for your command
713
714Cobra can generate documentation based on subcommands, flags, etc. in the following formats:
715
716- [Markdown](doc/md_docs.md)
717- [ReStructured Text](doc/rest_docs.md)
718- [Man Page](doc/man_docs.md)
719
720## Generating bash completions
721
722Cobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible.  Read more about it in [Bash Completions](bash_completions.md).
723
724## Generating zsh completions
725
726Cobra can generate zsh-completion file. Read more about it in
727[Zsh Completions](zsh_completions.md).
728
729# Contributing
730
7311. Fork it
7322. Download your fork to your PC (`git clone https://github.com/your_username/cobra && cd cobra`)
7333. Create your feature branch (`git checkout -b my-new-feature`)
7344. Make changes and add them (`git add .`)
7355. Commit your changes (`git commit -m 'Add some feature'`)
7366. Push to the branch (`git push origin my-new-feature`)
7377. Create new pull request
738
739# License
740
741Cobra is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/spf13/cobra/blob/master/LICENSE.txt)