Skip to content

Commit

Permalink
Make the subcommand if a switch
Browse files Browse the repository at this point in the history
  • Loading branch information
slarwise committed Aug 6, 2024
1 parent 1c8abac commit c53f832
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func main() {
fatal("Must provide subcommand `tree` or `get`")
}
subcommand := os.Args[1]
if subcommand == "tree" {
switch subcommand {
case "tree":
entrypoint := "/"
if len(os.Args) > 2 {
entrypoint = os.Args[2]
Expand All @@ -53,7 +54,7 @@ func main() {
for _, key := range keys {
fmt.Println(key)
}
} else if subcommand == "get" {
case "get":
if len(os.Args) < 3 {
fatal("Must provide the name of the secret, e.g. ./pole3 get my-secret")
}
Expand All @@ -70,7 +71,7 @@ func main() {
fatal("Could not marshal secret as json", "error", err)
}
fmt.Println(string(output))
} else if subcommand == "interactive" {
case "interactive":
slog.SetLogLoggerLevel(slog.LevelError)
screen, err := tcell.NewScreen()
if err != nil {
Expand Down Expand Up @@ -159,7 +160,7 @@ func main() {
}
screen.Show()
}
} else {
default:
fatal(fmt.Sprintf("Subcommand must be one of `tree` or `get`, got %s", subcommand))
}
}
Expand Down

0 comments on commit c53f832

Please sign in to comment.