hashicorp / hashicorp/nomad

Support optional flag arguments after positional arguments

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

Description

Nomad's CLI has always required positional arguments come after all optional flags:

```
# Works
$ nomad run foo.nomad
$ nomad run -detach foo.nomad

# Does not work
$ nomad run foo.nomad -detach
This command takes one argument:
For additional help try 'nomad job run -help'
```

As this causes some ambiguities, such as if there were a file named `-detach`, we would also need to support `-- [positional arguments]` syntax at the end of commands:

```
# Desired
$ nomad run foo.nomad -detach
$ nomad run -- -detach # Runs the file named -detach
```

It should be noted that the current behavior follows Go and BSD style, and the reordering behavior follows GNU style. I think the usability improvement is worth breaking out of our existing style, but it's definitely up for debate.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at Nomad's CLI entry point and locate the argument-parsing code and tests for the run command. Compare the current BSD-style behavior with the requested GNU-style reordering and `--` handling, then confirm the desired semantics before changing anything; done means both example forms work without breaking existing positional-argument behavior.

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
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.