dynamist / dynamist/phabfive

Proposal for fields output from diffusion list

Open
#50 0 comments 0 reactions 0 assignees View on GitHub
app:diffusion app:maniphest enhancement
Dominant language
Python
Stars
6
Forks
3
Avg merge
2h 18m
Merged PRs (30d)
8

Description

### Proposed Functionality

Background: The default for phabfive diffusion list is to print the name field.

Objective: Allow to specify fields of interest. An example:

`phabfive diffusion list --fields name,url,type`

Where the fields could map directly to data returned by the Phabricator API, but not necessarily, for example the url field would have to be assembled from various data from the API.

- name -- same as repository['fields']['name']
- url -- built from the above name plus a prefix and suffix
- type -- same as repository['fields']['vcs']

The output would be something similar to this:

```
$ phabfive diffusion list --fields url,type
ssh://dynamist@vault.phacility.com/source/phabfive.git,git
ssh://dynamist@vault.phacility.com/source/unifik.git,git
```

For now we will focus on CSV compliant output, JSON and/or YAML is not in scope.

---

(This section was suggested by @rholmboe)

OpenStack actually perfected it imho

This is the default output in the cli, which is for all modules (network, server, floating etc etc)

```
(openstack) $ git:(master) openstack network list -f table
+--------------------------------------+---------+----------------------------------------------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+---------+----------------------------------------------------------------------------+
| 42f2071d-273f-4445-b981-dd05776422ed | private | ae7bdddb-5c99-46f8-bab1-25efab1cba42 |
| 7b6935ef-4a13-41d1-b8fa-087927cb480b | public | 1993b658-8cf1-421a-a93f-e2de7b5dd06a, 5151480f-ae04-4619-b36f-3bdcc4de5342 |
+--------------------------------------+---------+----------------------------------------------------------------------------+
```

in yaml

```
(openstack) $ git:(master) openstack network list -c ID -c Subnets -f yaml
- ID: 42f2071d-273f-4445-b981-dd05776422ed
Subnets: ae7bdddb-5c99-46f8-bab1-25efab1cba42
- ID: 7b6935ef-4a13-41d1-b8fa-087927cb480b
Subnets: 1993b658-8cf1-421a-a93f-e2de7b5dd06a, 5151480f-ae04-4619-b36f-3bdcc4de5342
```

in csv

```
(openstack) $ git:(master) openstack network list -f csv
"ID","Name","Subnets"
"42f2071d-273f-4445-b981-dd05776422ed","private","ae7bdddb-5c99-46f8-bab1-25efab1cba42"
"7b6935ef-4a13-41d1-b8fa-087927cb480b","public","1993b658-8cf1-421a-a93f-e2de7b5dd06a, 5151480f-ae04-4619-b36f-3bdcc4de5342"
```

in json

```
(openstack) $ git:(master) openstack network list -c Name -c Subnets -f json
[
{
"Subnets": "ae7bdddb-5c99-46f8-bab1-25efab1cba42",
"Name": "private"
},
{
"Subnets": "1993b658-8cf1-421a-a93f-e2de7b5dd06a, 5151480f-ae04-4619-b36f-3bdcc4de5342",
"Name": "public"
}
]
```

Just the values

```
(openstack) $ git:(master) openstack network list -c ID -f value
42f2071d-273f-4445-b981-dd05776422ed
7b6935ef-4a13-41d1-b8fa-087927cb480b
```

From the helper

```
output formatters:
output formatter options

-f {csv,json,table,value,yaml}, --format {csv,json,table,value,yaml}
the output format, defaults to table
-c COLUMN, --column COLUMN
specify the column(s) to include, can be repeated
--sort-column SORT_COLUMN
specify the column(s) to sort the data (columns
specified first have a priority, non-existing columns
are ignored), can be repeated
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.