Skip to content

Commit

Permalink
[fix] Print help for exec when no args are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
pjg11 committed Jun 18, 2024
1 parent 02551ed commit 6a4ca15
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ var (
)

func execEntrypoint(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()

Check failure on line 36 in cmd/exec.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `cmd.Help` is not checked (errcheck)
os.Exit(0)
}

allocID := args[0]
execArgs := args[1:]
if len(execArgs) == 0 {
fmt.Println(fmt.Errorf("no command specified"))
os.Exit(1)
}
task := cmd.Flags().Lookup("task").Value.String()
// can ignore storing rootOpts here as exec just needs a client
config := getConfig(cmd, []string{}, "")
Expand All @@ -40,12 +51,7 @@ func execEntrypoint(cmd *cobra.Command, args []string) {
fmt.Println(fmt.Errorf("could not get client: %v", err))
os.Exit(1)
}
allocID := args[0]
execArgs := args[1:]
if len(execArgs) == 0 {
fmt.Println("no command specified")
os.Exit(1)
}

_, err = nomad.AllocExec(client, allocID, task, execArgs)
if err != nil {
fmt.Println(fmt.Errorf("could not exec into task: %v", err))
Expand Down

0 comments on commit 6a4ca15

Please sign in to comment.