asdf-vm / asdf-vm/asdf

Add `--porcelain` and other flags for formatting command output

Open
#1,291 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
25.6k
Forks
941
Avg merge
9h 24m
Merged PRs (30d)
3

Description

### Is your feature request related to a problem? Please describe

Currently asdf commands generate output that is intended to be read by humans and also consumed by other programs on the command line. Humans and computers often need different information, and need output formatted in different ways.

### Describe the proposed solution

I propose we add a `--porcelain` flag to all asdf commands. The `--porcelain` flag should cause the output to conform to the following rules:

* No column headers
* No variable formatting (e.g. wrapping after a certain number of columns)
* When outputting tabular data, easy to parse rows and columns (need more specifics here)

Additionally, each command could have a small number of flags specific to the fields the command can output that turns that field on or off. For example, `asdf current` outputs plugin name, current version, and place the version was set for each row. Each of these fields could be toggled on or off with a flag. Alternatively we could possibly use a format flag with a format string that we pass to `printf`. For example:

```
$ asdf current --format="%s:%s"
```

### Describe similar `asdf` features and why they are not sufficient

None

### Describe other workarounds you've considered

None

### Related

* https://github.com/asdf-vm/asdf/pull/762#issuecomment-1176877365
* https://github.com/asdf-vm/asdf/issues/646#issuecomment-650210276
* https://github.com/asdf-vm/asdf/issues/866#issuecomment-776612435

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing output paths for asdf commands, especially the `asdf current` entry point, and read the related discussions in issues 646 and 866 and PR 762. Define the exact porcelain and field-format contracts for each command before implementation; done means the scope, output rules, and automated coverage are agreed and all affected commands follow them.

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.