Skip to content

Commit

Permalink
When n isn't specified, bring up a prompt instead of an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
benprew committed Oct 15, 2020
1 parent 7eb07c1 commit dcf130f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cmd/stashbox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,25 @@ func main() {
openCmd.Usage()
os.Exit(2)
}
if *n < 1 {
fmt.Println("Error: -n is required")
openCmd.Usage()
os.Exit(1)
}
archives, err := archive.GetArchives(*openBase)
if err != nil {
panic(err)
}

if *n < 1 {
fmt.Println("Choose an archive to open:")
for i, n := range archives {
fmt.Printf("%d. %s [%d image(s)]\n", i+1, n.URL, len(n.Dates))
}
fmt.Print("\n> ")
_, err := fmt.Scanf("%d", n)

if err != nil {
fmt.Printf("ERROR: reading input: %v", err)
os.Exit(1)
}
}

a := archives[*n-1]

file := fmt.Sprintf("%s/%s/%s.pdf", *openBase, a.URL, a.Dates[len(a.Dates)-1])
Expand Down

0 comments on commit dcf130f

Please sign in to comment.