diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-07-09 18:08:07 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-07-09 18:08:07 -0700 |
| commit | a4a5a4cff51a8ec18517da4ee030da818cb2a9ab (patch) | |
| tree | b12ebb9653eb58aba86e957009ed4fb5c5e66bf3 | |
| parent | 93295a58ea02a8eb68dcaa5a283d057bd1749db1 (diff) | |
| download | git-shell-commands-a4a5a4cff51a8ec18517da4ee030da818cb2a9ab.tar.zst | |
Add a help command
| -rw-r--r-- | git-shell-commands.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/git-shell-commands.go b/git-shell-commands.go index d331ef5..2040e23 100644 --- a/git-shell-commands.go +++ b/git-shell-commands.go @@ -97,15 +97,27 @@ Delete the git repo named REPO. return nil } +func help() { + fmt.Printf(`Available commands: + create create a new git repo + delete delete a git repo + help print this message +`) +} + func main() { + cmd := filepath.Base(os.Args[0]) var err error - if filepath.Base(os.Args[0]) == "delete" { - err = delete() - } else { + switch cmd { + case "create": err = create() + case "delete": + err = delete() + default: + help() } if err != nil { - fmt.Fprintln(os.Stderr, err) + fmt.Fprintf(os.Stderr, "%s\nUse %s -help for usage info\n", err, cmd) os.Exit(1) } } |
