This repository was archived by the owner on Aug 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Original file line number Diff line number Diff line change @@ -52,25 +52,22 @@ func main() {
5252 log .SetPrefix ("wire: " )
5353 log .SetOutput (os .Stderr )
5454
55- // TODO(rvangent): Use subcommands's VisitCommands instead of hardcoded map,
56- // once there is a release that contains it:
57- // allCmds := map[string]bool{}
58- // subcommands.DefaultCommander.VisitCommands(func(_ *subcommands.CommandGroup, cmd subcommands.Command) { allCmds[cmd.Name()] = true })
59- allCmds := map [string ]bool {
60- "commands" : true , // builtin
61- "help" : true , // builtin
62- "flags" : true , // builtin
63- "check" : true ,
64- "diff" : true ,
65- "gen" : true ,
66- "show" : true ,
55+ if args := flag .Args (); len (args ) != 0 {
56+ argCmd := args [0 ]
57+ subcommands .DefaultCommander .VisitCommands (func (cg * subcommands.CommandGroup , cmd subcommands.Command ) {
58+ if cg .Name () != "" {
59+ return
60+ }
61+ if cmd .Name () == argCmd {
62+ // Execute command from argument.
63+ os .Exit (int (subcommands .Execute (context .Background ())))
64+ }
65+ })
6766 }
67+
6868 // Default to running the "gen" command.
69- if args := flag .Args (); len (args ) == 0 || ! allCmds [args [0 ]] {
70- genCmd := & genCmd {}
71- os .Exit (int (genCmd .Execute (context .Background (), flag .CommandLine )))
72- }
73- os .Exit (int (subcommands .Execute (context .Background ())))
69+ genCmd := & genCmd {}
70+ os .Exit (int (genCmd .Execute (context .Background (), flag .CommandLine )))
7471}
7572
7673// packages returns the slice of packages to run wire over based on f.
You can’t perform that action at this time.
0 commit comments