hashicorp / hashicorp/nomad

Provide helper function to retrieve default coloumns when using `-t`

Open
#16,347 0 comments 0 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

### Proposal
Add a new helper function to be used in CLI outputs with `-t` that provides the default columns for the command.

### Use-cases
When using `-t` to format a command output users have to declare all the columns they want. In some cases all that is needed is to expand the default output with a few more values, but currently this requires re-declaring all columns.

For example, `nomad node status` outputs the following:

```console
$ nomad node status
ID DC Name Class Drain Eligibility Status
83a42fd9 dc1 laoqui-GDP2M7PY2N false eligible ready
```

To add a new column we would need to do run the command as:

```console
$ nomad node status -t '{{range .}}{{.ID}} {{.Datacenter}} {{.Name}} {{.NodeClass}} {{.Drain}} {{.SchedulingEligibility}} {{.Version}}{{end}}'
83a42fd9-7864-753d-f6b2-42900171fb33 dc1 laoqui-GDP2M7PY2N false eligible 1.5.0
```

If a helper function were available this command could be reduced to:

```console
$ nomad node status -t '{{range .}}{{.DefaultColoumns}} {{.Version}}{{end}}'
83a42fd9-7864-753d-f6b2-42900171fb33 dc1 laoqui-GDP2M7PY2N false eligible 1.5.0
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the CLI implementation for `nomad node status` and how its default columns are assembled for `-t` output. Identify the relevant output paths and tests, then verify that a helper exposes the default columns for templates without requiring users to redeclare them.

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.