Add `campaigns list` subcommand
Created by: mrnugget
This allows the users to list campaigns and get the campaign IDs they
need to use the campaigns add-changesets
command.
The default rendering template is {{.ID}}: {{.Name}}
but users can
specify more fields or get a JSON dump of all of them with the described
{{.|json}}
pipe:
$ src campaigns list -first 1
Q2FtcGFpZ246NA==: testing the src cli
$ src campaigns list -first 1 -f '{{. |json}}' | jq .
{
"ID": "Q2FtcGFpZ246NA==",
"Name": "testing the src cli",
"Description": "This campaign is here to test the `src` cli tool.",
"CreatedAt": "2019-09-20T05:49:54Z",
"UpdatedAt": "2019-09-20T13:07:55Z",
"Changesets": {
"Nodes": [
{
"ID": "Q2hhbmdlc2V0OjM1",
"State": "CLOSED",
"ReviewState": "APPROVED",
"Repository": {
"ID": "UmVwb3NpdG9yeTo0Mg==",
"Name": "github.com/sourcegraph/sourcegraph"
},
"ExternalURL": {
"URL": "https://github.com/sourcegraph/sourcegraph/pull/5003",
"ServiceType": "github"
},
"CreatedAt": "2019-09-20T06:30:20Z",
"UpdatedAt": "2019-09-20T13:32:04Z"
},
{
"ID": "Q2hhbmdlc2V0OjM5",
"State": "MERGED",
"ReviewState": "APPROVED",
"Repository": {
"ID": "UmVwb3NpdG9yeTo0Mg==",
"Name": "github.com/sourcegraph/sourcegraph"
},
"ExternalURL": {
"URL": "https://github.com/sourcegraph/sourcegraph/pull/5005",
"ServiceType": "github"
},
"CreatedAt": "2019-09-20T06:32:14Z",
"UpdatedAt": "2019-09-20T13:32:04Z"
}
],
"TotalCount": 2
}
}