mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
This confused me: ``` terminal command () doesn't define an Exec function ``` Now it prints a help text. Test plan: Verified the above behavior by hand.
41 lines
707 B
Go
41 lines
707 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/peterbourgon/ff/v3/ffcli"
|
|
)
|
|
|
|
func main() {
|
|
if err := mainErr(); err != nil {
|
|
fmt.Printf("error: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
var rootFlagSet = flag.NewFlagSet("depgraph", flag.ExitOnError)
|
|
var rootCommand = &ffcli.Command{
|
|
ShortUsage: "depgraph [flags] <subcommand>",
|
|
FlagSet: rootFlagSet,
|
|
Exec: func(ctx context.Context, args []string) error {
|
|
return flag.ErrHelp
|
|
},
|
|
Subcommands: []*ffcli.Command{
|
|
summaryCommand,
|
|
traceCommand,
|
|
traceInternalCommand,
|
|
lintCommand,
|
|
},
|
|
}
|
|
|
|
func mainErr() error {
|
|
if err := rootCommand.Parse(os.Args[1:]); err != nil {
|
|
return err
|
|
}
|
|
|
|
return rootCommand.Run(context.Background())
|
|
}
|