func main()

in cmd/swctl/main.go [66:131]


func main() {
	app := cli.NewApp()
	app.Name = "swctl"
	app.Usage = "The CLI (Command Line Interface) for Apache SkyWalking."
	app.UsageText = `Commands in SkyWalking CLI are organized into two levels,
in the form of "swctl --option <level1> --option <level2> --option",
there are options in each level, which should follow right after
the corresponding command, take the following command as example:

	$ swctl --debug service list --start="2019-11-11" --end="2019-11-12"

where "--debug" is is an option of "swctl", and since the "swctl" is
a top-level command, "--debug" is also called global option, and "--start"
is an option of the third level command "list", there is no option for the
second level command "service".

Generally, the second level commands are entity related, there are entities
like "service", "service instance", "metrics" in SkyWalking, and we have
corresponding sub-command like "service"; the third level commands are
operations on the entities, such as "list" command will list all the
services, service instances, etc.`
	app.Version = version

	flags := flags()

	app.Commands = []*cli.Command{
		browser.Command,
		endpoint.Command,
		instance.Command,
		service.Command,
		metrics.Command,
		trace.Command,
		healthcheck.Command,
		dashboard.Command,
		install.Command,
		event.Command,
		logs.Command,
		completion.Command,
		dependency.Command,
		alarm.Command,
		layer.Command,
		process.Command,
		profiling.Command,
		records.Command,
		menu.Command,
	}

	app.Before = interceptor.BeforeChain(
		setUpCommandLineContext,
		expandConfigFile,
		tryConfigFile(flags),
	)

	app.Flags = flags
	app.CommandNotFound = util.CommandNotFound

	// Enable auto-completion.
	app.EnableBashCompletion = true
	cli.BashCompletionFlag = &cli.BoolFlag{
		Name:   "auto_complete",
		Hidden: true,
	}
	if err := app.Run(os.Args); err != nil {
		log.Fatalln(err)
	}
}