From 10ba2246f9b5285f5118a5ba5be134724af4bbe0 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Sun, 25 Sep 2022 08:05:34 -0400 Subject: refactor(git-bug-863): merge ls-id into ls The "ls" command allows filtering and sorting and already features different output formatters. Merging "ls-id" into "ls" cleans up the command hierarchy and allows users to take advantage of these querying features. Resolves #863. --- commands/ls-id.go | 7 +++++++ commands/ls.go | 14 ++++++++++++-- commands/ls_test.go | 1 + doc/man/git-bug-ls-id.1 | 27 --------------------------- doc/man/git-bug-ls.1 | 2 +- doc/man/git-bug.1 | 2 +- doc/md/git-bug.md | 1 - doc/md/git-bug_ls-id.md | 18 ------------------ doc/md/git-bug_ls.md | 2 +- 9 files changed, 23 insertions(+), 51 deletions(-) delete mode 100644 doc/man/git-bug-ls-id.1 delete mode 100644 doc/md/git-bug_ls-id.md diff --git a/commands/ls-id.go b/commands/ls-id.go index 41f017e8..31107e87 100644 --- a/commands/ls-id.go +++ b/commands/ls-id.go @@ -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 diff --git a/commands/ls.go b/commands/ls.go index 6ec06f39..7ed897fa 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -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) diff --git a/commands/ls_test.go b/commands/ls_test.go index 5759f9d0..b53092b4 100644 --- a/commands/ls_test.go +++ b/commands/ls_test.go @@ -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]{7}\n$"}, {"org-mode", expOrgMode}, } diff --git a/doc/man/git-bug-ls-id.1 b/doc/man/git-bug-ls-id.1 deleted file mode 100644 index eebdf421..00000000 --- a/doc/man/git-bug-ls-id.1 +++ /dev/null @@ -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 diff --git a/doc/man/git-bug-ls.1 b/doc/man/git-bug-ls.1 index 873cf68c..e58177de 100644 --- a/doc/man/git-bug-ls.1 +++ b/doc/man/git-bug-ls.1 @@ -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] diff --git a/doc/man/git-bug.1 b/doc/man/git-bug.1 index 47e433ae..419bb2c7 100644 --- a/doc/man/git-bug.1 +++ b/doc/man/git-bug.1 @@ -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 diff --git a/doc/md/git-bug.md b/doc/md/git-bug.md index 99b554e2..754cc93f 100644 --- a/doc/md/git-bug.md +++ b/doc/md/git-bug.md @@ -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. diff --git a/doc/md/git-bug_ls-id.md b/doc/md/git-bug_ls-id.md deleted file mode 100644 index 493a1829..00000000 --- a/doc/md/git-bug_ls-id.md +++ /dev/null @@ -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. - diff --git a/doc/md/git-bug_ls.md b/doc/md/git-bug_ls.md index a40b3fd9..5aec0fbc 100644 --- a/doc/md/git-bug_ls.md +++ b/doc/md/git-bug_ls.md @@ -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 ``` -- cgit