Merge pull request #883 from MichaelMure/refactor-863-merge-ls-id-into-ls

refactor(863): merge ls-id into ls
This commit is contained in:
Michael Muré 2022-09-25 16:46:13 +02:00 committed by GitHub
commit 8364cb221b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 51 deletions

View File

@ -14,6 +14,13 @@ func newLsIdCommand() *cobra.Command {
RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
return runLsId(env, args)
}),
Deprecated: `and will be removed in v1.0.
Please use the "ls" command which allows filtering and sorting of the resulting
list of ids. The following example would print a new-line separated list containing
the ids of all open bugs:
git-bug ls --format id --status open
`,
}
return cmd

View File

@ -92,9 +92,9 @@ git bug ls status:open --by creation "foo bar" baz
"Select the sorting direction. Valid values are [asc,desc]")
cmd.RegisterFlagCompletionFunc("direction", completeFrom([]string{"asc", "desc"}))
flags.StringVarP(&options.outputFormat, "format", "f", "default",
"Select the output formatting style. Valid values are [default,plain,compact,json,org-mode]")
"Select the output formatting style. Valid values are [default,plain,compact,id,json,org-mode]")
cmd.RegisterFlagCompletionFunc("format",
completeFrom([]string{"default", "plain", "compact", "json", "org-mode"}))
completeFrom([]string{"default", "plain", "compact", "id", "json", "org-mode"}))
return cmd
}
@ -143,6 +143,8 @@ func runLs(env *Env, opts lsOptions, args []string) error {
return lsJsonFormatter(env, bugExcerpt)
case "compact":
return lsCompactFormatter(env, bugExcerpt)
case "id":
return lsIDFormatter(env, bugExcerpt)
case "default":
return lsDefaultFormatter(env, bugExcerpt)
default:
@ -252,6 +254,14 @@ func lsCompactFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
return nil
}
func lsIDFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
env.out.Println(b.Id.String())
}
return nil
}
func lsDefaultFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)

View File

@ -61,6 +61,7 @@ $`
{"default", "^[0-9a-f]{7}\topen\tthis is a bug title \tJohn Doe \t\n$"},
{"plain", "^[0-9a-f]{7} \\[open\\] this is a bug title\n$"},
{"compact", "^[0-9a-f]{7} open this is a bug title John Doe\n$"},
{"id", "^[0-9a-f]{64}\n$"},
{"org-mode", expOrgMode},
}

View File

@ -1,27 +0,0 @@
.nh
.TH "GIT-BUG" "1" "Apr 2019" "Generated from git-bug's source code" ""
.SH NAME
.PP
git-bug-ls-id - List bug identifiers.
.SH SYNOPSIS
.PP
\fBgit-bug ls-id [PREFIX] [flags]\fP
.SH DESCRIPTION
.PP
List bug identifiers.
.SH OPTIONS
.PP
\fB-h\fP, \fB--help\fP[=false]
help for ls-id
.SH SEE ALSO
.PP
\fBgit-bug(1)\fP

View File

@ -62,7 +62,7 @@ You can pass an additional query to filter and order the list. This query can be
.PP
\fB-f\fP, \fB--format\fP="default"
Select the output formatting style. Valid values are [default,plain,compact,json,org-mode]
Select the output formatting style. Valid values are [default,plain,compact,id,json,org-mode]
.PP
\fB-h\fP, \fB--help\fP[=false]

View File

@ -29,4 +29,4 @@ the same git remote you are already using to collaborate with other people.
.SH SEE ALSO
.PP
\fBgit-bug-add(1)\fP, \fBgit-bug-bridge(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-comment(1)\fP, \fBgit-bug-deselect(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-ls(1)\fP, \fBgit-bug-ls-id(1)\fP, \fBgit-bug-ls-label(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-rm(1)\fP, \fBgit-bug-select(1)\fP, \fBgit-bug-show(1)\fP, \fBgit-bug-status(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-title(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP
\fBgit-bug-add(1)\fP, \fBgit-bug-bridge(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-comment(1)\fP, \fBgit-bug-deselect(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-ls(1)\fP, \fBgit-bug-ls-label(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-rm(1)\fP, \fBgit-bug-select(1)\fP, \fBgit-bug-show(1)\fP, \fBgit-bug-status(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-title(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP

View File

@ -31,7 +31,6 @@ git-bug [flags]
* [git-bug deselect](git-bug_deselect.md) - Clear the implicitly selected bug.
* [git-bug label](git-bug_label.md) - Display, add or remove labels to/from a bug.
* [git-bug ls](git-bug_ls.md) - List bugs.
* [git-bug ls-id](git-bug_ls-id.md) - List bug identifiers.
* [git-bug ls-label](git-bug_ls-label.md) - List valid labels.
* [git-bug pull](git-bug_pull.md) - Pull bugs update from a git remote.
* [git-bug push](git-bug_push.md) - Push bugs update to a git remote.

View File

@ -1,18 +0,0 @@
## git-bug ls-id
List bug identifiers.
```
git-bug ls-id [PREFIX] [flags]
```
### Options
```
-h, --help help for ls-id
```
### SEE ALSO
* [git-bug](git-bug.md) - A bug tracker embedded in Git.

View File

@ -42,7 +42,7 @@ git bug ls status:open --by creation "foo bar" baz
-n, --no strings Filter by absence of something. Valid values are [label]
-b, --by string Sort the results by a characteristic. Valid values are [id,creation,edit] (default "creation")
-d, --direction string Select the sorting direction. Valid values are [asc,desc] (default "asc")
-f, --format string Select the output formatting style. Valid values are [default,plain,compact,json,org-mode] (default "default")
-f, --format string Select the output formatting style. Valid values are [default,plain,compact,id,json,org-mode] (default "default")
-h, --help help for ls
```