()
| 19 | ) |
| 20 | |
| 21 | func main() { |
| 22 | // Handle default case: if first arg looks like a PR ref, run diff |
| 23 | if len(os.Args) > 1 && looksLikePRRef(os.Args[1]) { |
| 24 | if err := runDiffDirect(os.Args[1], os.Args[2:]); err != nil { |
| 25 | fmt.Fprintln(os.Stderr, err) |
| 26 | os.Exit(1) |
| 27 | } |
| 28 | return |
| 29 | } |
| 30 | |
| 31 | app := snap.New(commandName, "GitHub CLI for PR operations"). |
| 32 | Version(version) |
| 33 | |
| 34 | app.Command("diff", "Get full diff of a GitHub PR"). |
| 35 | Action(runDiff) |
| 36 | |
| 37 | app.Command("version", "Show version"). |
| 38 | Action(func(ctx *snap.Context) error { |
| 39 | fmt.Fprintln(ctx.Stdout(), version) |
| 40 | return nil |
| 41 | }) |
| 42 | |
| 43 | app.Command("deploy", "Build and install ghx to ~/bin"). |
| 44 | Action(runDeploy) |
| 45 | |
| 46 | if len(os.Args) == 1 { |
| 47 | showHelpDirect() |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | app.RunAndExit() |
| 52 | } |
| 53 | |
| 54 | func showHelpDirect() { |
| 55 | fmt.Printf("%s - GitHub CLI for PR operations\n\n", commandName) |
nothing calls this directly
no test coverage detected