命令行标志和命令

I need to start working on command line tool, and I’ve few questions

we have decided to use cobra for go https://github.com/spf13/cobra

From the help :

$ cobra help

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.

Usage:
  cobra [command]

Available Commands:
  add         Add a command to a Cobra Application
  help        Help about any command
  init        Initialize a Cobra Application

Flags:
  -a, --author string    author name for copyright attribution (default "YOUR NAME")
      --config string    config file (default is $HOME/.cobra.yaml)
  -h, --help             help for cobra
  -l, --license string   name of license for the project
      --viper            use Viper for configuration (default true)

Use "cobra [command] --help" for more information about a command.

My questions are:

  1. what is the relations/diff between commands and flags (Available Commands) semantic ….
  2. is there is relations between command and flags
  3. Are single command should support flags
  4. in case in Need to provide command like deploy to x should it be ‘deploy -x’

A command tells the application what to do, for example "tool sayhello". Flags are used to pass information required by the application to achieve its task, for example "tool sayhello --message='Hello World'". Flags are often shortened by using their first letter and one hyphen.

How you design the commands and flags of your application is up to you. If you want to create a deployment tool for example, you could create a command "deploy" and a flag for the machine to deploy to: "tool deploy --machine=hostip".