Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Print help for exec when no args are provided #138

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
)

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 @@
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
Loading