hashicorp / hashicorp/nomad

consistent ordering for CLI parameters

Open
#9,441 4 comments 2 reactions 0 assignees View on GitHub
stage/accepted theme/cli type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Issue
When using flags with nomad cli commands there are seemingly needless requirements for where the flags are written in the command, and whether the parameters are flags or arguments also varies. This is a big annoyance since the position requirements of the flags also differ between commands, resulting in growing frustration among our users.

**Example 1:**
`nomad alloc status -verbose 34a63710` works, but `nomad alloc status 34a63710 -verbose` does not.

**Example 2:**
Sometimes the `task` parameter is defined as a flag for a command, and sometimes not: \
When reading logs the task is passed as an argument:
`nomad alloc logs -f -tail 28403873 galera-node`

I actually got frustrated with this myself, just writing this issue and trying to show examples, this is a great example of why this needs reworking:

```
nomad exec -i -t 28403873 sh
Allocation "28403873" is running the following tasks:
* host-dir-setup
* galera-node

Please specify the task.
```

Okay... "specify the task", naturally it should be the same way as with `nomad alloc logs`, right?

```
nomad exec -i -t 28403873 galera-node sh
Allocation "28403873" is running the following tasks:
* host-dir-setup
* galera-node

Please specify the task.
```

Nope - that didn't work, according to the help we need to set `task` as a flag here instead:
```
nomad exec -i -t -task galera-node 28403873 sh
```

Note that for the `nomad exec` command you need to specify the task **before** the allocation ID, while for the `nomad alloc logs` its passed **after** the allocation ID, this kind of inconsistent behavior between commands is really confusing and time consuming because you have to start figuring out how the flags and args are supposed to be passed for different commands.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the parameter definitions and help behavior for `nomad exec` and `nomad alloc logs`, especially task and allocation arguments. Done means CLI commands accept flags and positional parameters consistently, with matching ordering and clear usage across the affected commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.