type Profile … type Application … type SubCommand … type commandLineError … func (e commandLineError) Error() string { … } // CommandLineErrorf is like fmt.Errorf except that it returns a value that // triggers printing of the command line help. // In general you should use this when generating command line validation errors. func CommandLineErrorf(message string, args ...interface{ … } // Main should be invoked directly by main function. // It will only return if there was no error. If an error // was encountered it is printed to standard error and the // application exits with an exit code of 2. func Main(ctx context.Context, app Application, args []string) { … } // Run is the inner loop for Main; invoked by Main, recursively by // Run, and by various tests. It runs the application and returns an // error. func Run(ctx context.Context, s *flag.FlagSet, app Application, args []string) (resultErr error) { … } // addFlags scans fields of structs recursively to find things with flag tags // and add them to the flag set. func addFlags(f *flag.FlagSet, field reflect.StructField, value reflect.Value) *Profile { … } func addFlag(f *flag.FlagSet, value reflect.Value, flagName string, help string) { … } func resolve(v reflect.Value) reflect.Value { … }