diff --git a/commands/status.go b/commands/status.go new file mode 100644 index 0000000000000000000000000000000000000000..29646b6e1dbc77efefdc58bb71031b742bdd5b7b --- /dev/null +++ b/commands/status.go @@ -0,0 +1,50 @@ +package commands + +import ( + "fmt" + + "github.com/MichaelMure/git-bug/cache" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +func runStatus(cmd *cobra.Command, args []string) error { + var err error + + if len(args) > 1 { + return errors.New("Only one bug id is supported") + } + + if len(args) == 0 { + return errors.New("You must provide a bug id") + } + + backend, err := cache.NewRepoCache(repo) + if err != nil { + return err + } + defer backend.Close() + + prefix := args[0] + + b, err := backend.ResolveBugPrefix(prefix) + if err != nil { + return err + } + + snap := b.Snapshot() + + fmt.Println(snap.Status) + + return nil +} + +var statusCmd = &cobra.Command{ + Use: "status ", + Short: "Show the bug status", + RunE: runStatus, +} + +func init() { + RootCmd.AddCommand(statusCmd) +} diff --git a/doc/man/git-bug-status.1 b/doc/man/git-bug-status.1 new file mode 100644 index 0000000000000000000000000000000000000000..076791e82c94ab0d3be57d12218ecc1ee27ced7a --- /dev/null +++ b/doc/man/git-bug-status.1 @@ -0,0 +1,29 @@ +.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" "" +.nh +.ad l + + +.SH NAME +.PP +git\-bug\-status \- Show the bug status + + +.SH SYNOPSIS +.PP +\fBgit\-bug status [flags]\fP + + +.SH DESCRIPTION +.PP +Show the bug status + + +.SH OPTIONS +.PP +\fB\-h\fP, \fB\-\-help\fP[=false] + help for status + + +.SH SEE ALSO +.PP +\fBgit\-bug(1)\fP diff --git a/doc/man/git-bug.1 b/doc/man/git-bug.1 index 514dc093f74308d486ea6170aa45b10b7e64ce12..7c6879fa60518e6a2a4070f4514e5f7cad8d888e 100644 --- a/doc/man/git-bug.1 +++ b/doc/man/git-bug.1 @@ -29,4 +29,4 @@ It use the same internal storage so it doesn't pollute your project. As you woul .SH SEE ALSO .PP -\fBgit\-bug\-add(1)\fP, \fBgit\-bug\-close(1)\fP, \fBgit\-bug\-commands(1)\fP, \fBgit\-bug\-comment(1)\fP, \fBgit\-bug\-label(1)\fP, \fBgit\-bug\-ls(1)\fP, \fBgit\-bug\-open(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(1)\fP, \fBgit\-bug\-show(1)\fP, \fBgit\-bug\-termui(1)\fP, \fBgit\-bug\-title(1)\fP, \fBgit\-bug\-webui(1)\fP +\fBgit\-bug\-add(1)\fP, \fBgit\-bug\-close(1)\fP, \fBgit\-bug\-commands(1)\fP, \fBgit\-bug\-comment(1)\fP, \fBgit\-bug\-label(1)\fP, \fBgit\-bug\-ls(1)\fP, \fBgit\-bug\-open(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(1)\fP, \fBgit\-bug\-show(1)\fP, \fBgit\-bug\-status(1)\fP, \fBgit\-bug\-termui(1)\fP, \fBgit\-bug\-title(1)\fP, \fBgit\-bug\-webui(1)\fP diff --git a/doc/md/git-bug.md b/doc/md/git-bug.md index 9eb7b7bc41c02ef0964391ed33eddbc5c3db773f..33ab48ae49283b417046386db7b3e153cd093571 100644 --- a/doc/md/git-bug.md +++ b/doc/md/git-bug.md @@ -30,6 +30,7 @@ git-bug [flags] * [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 * [git-bug show](git-bug_show.md) - Display the details of a bug +* [git-bug status](git-bug_status.md) - Show the bug status * [git-bug termui](git-bug_termui.md) - Launch the terminal UI * [git-bug title](git-bug_title.md) - Display a bug's title * [git-bug webui](git-bug_webui.md) - Launch the web UI diff --git a/doc/md/git-bug_status.md b/doc/md/git-bug_status.md new file mode 100644 index 0000000000000000000000000000000000000000..a4af6f4d3272211d79aaa89339595466376637d9 --- /dev/null +++ b/doc/md/git-bug_status.md @@ -0,0 +1,22 @@ +## git-bug status + +Show the bug status + +### Synopsis + +Show the bug status + +``` +git-bug status [flags] +``` + +### Options + +``` + -h, --help help for status +``` + +### SEE ALSO + +* [git-bug](git-bug.md) - A bugtracker embedded in Git + diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug index f5f3da2a542bf1bd89d0922823f15aa26c43f413..973eff9c40f8d4e0ef2ef03a521f255131149094 100644 --- a/misc/bash_completion/git-bug +++ b/misc/bash_completion/git-bug @@ -508,6 +508,26 @@ _git-bug_show() noun_aliases=() } +_git-bug_status() +{ + last_command="git-bug_status" + + command_aliases=() + + commands=() + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + _git-bug_termui() { last_command="git-bug_termui" @@ -612,6 +632,7 @@ _git-bug_root_command() commands+=("pull") commands+=("push") commands+=("show") + commands+=("status") commands+=("termui") commands+=("title") commands+=("webui") diff --git a/misc/zsh_completion/git-bug b/misc/zsh_completion/git-bug index 60ae6ce9573e77f009b6d87e8addec6746a63dd3..38d72c24e06c97e55cce45f3a603b58b56695a94 100644 --- a/misc/zsh_completion/git-bug +++ b/misc/zsh_completion/git-bug @@ -8,7 +8,7 @@ case $state in level1) case $words[1] in git-bug) - _arguments '1: :(add close commands comment label ls open pull push show termui title webui)' + _arguments '1: :(add close commands comment label ls open pull push show status termui title webui)' ;; *) _arguments '*: :_files'