hashicorp / hashicorp/nomad

cli: Add support for `-q` flag to list and `nomad status` commands

Open
#12,430 0 comments 0 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

### Proposal

In PR #12426 a community member introduced the `-q` flag to the `node status` command. When specified, this flag will limit the output to just the UUIDs of the nodes. This flag could be useful for at least any list command as well as the generic `nomad status` command. This issue proposes that we expose the `-q` flag on all list commands as well as the `nomad status` command.

During the PR process, the following observation was made by @tgross

> There's probably a good argument to collect all the list-related args together somehow, but we don't yet have consistent implementation of those args across 100% of commands.

This issue also proposes that we attempt to address that consistency of implementation while adding this flag.

### Use-cases

This is useful for scripting automation. For example, looping over a list of node/alloc/job ids to take some action.

### Attempted Solutions

While it is possible to achieve this type of functionality by piping output to something like `awk` or `jq`, this would still be a nice quality of life improvement and probably less error prone for users.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the existing `-q` implementation for `node status` from PR #12426, then inventory the list commands and generic `nomad status` entry points. Compare how list-related arguments are implemented and define consistent behavior; done means the requested commands expose `-q` and return only UUIDs for scripting.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.