Skip to content

Commit

Permalink
printing help on missing arg
Browse files Browse the repository at this point in the history
  • Loading branch information
roblaszczak committed Nov 11, 2021
1 parent 0528a21 commit 8d0ff4f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"errors"
"fmt"
"io"
"log"
"os"
Expand Down Expand Up @@ -57,8 +57,10 @@ func main() {
},
Action: func(c *cli.Context) error {
token := c.Args().First()

if token == "" {
return errors.New("missing token argument")
fmt.Print("Missing token argument! Usage:\n\n")
cli.ShowSubcommandHelpAndExit(c, 1)
}

return trainings.ConfigureGlobally(token, c.String("server"), c.Bool("override"))
Expand All @@ -81,12 +83,14 @@ func main() {
},
{
Name: "init",
ArgsUsage: "[training id]",
ArgsUsage: "[trainingID]",
Usage: "initialise training files in your current directory",
Action: func(c *cli.Context) error {
trainingID := c.Args().First()

if trainingID == "" {
return errors.New("missing trainingID argument")
fmt.Print("Missing trainingID argument! Usage:\n\n")
cli.ShowSubcommandHelpAndExit(c, 1)
}

return trainings.Init(trainingID)
Expand Down

0 comments on commit 8d0ff4f

Please sign in to comment.