Skip to content
Snippets Groups Projects
Unverified Commit 93115429 authored by sudoforge's avatar sudoforge Committed by GitHub
Browse files

refactor(cli)!: remove the 'commands' command (#1462)

This change removes the 'commands' command. This command historically
printed out all of the commands, optionally with help text. This is
superfluous, as we ship a manpage for each of the common shells, have
markdown documentation available in the repository, and provide help
text via the `--help` flag.

BREAKING-CHANGE: The `commands` command has been removed. There is no
replacement
 planned. Users are encouraged to run `--help`, view the markdown
 documentation available online, or run `man git-bug` to view the
 manpage in your terminal.
Change-Id: I8bbfb03c03c820ec0b56549e59ab76826c45b9cc
parent 170ce48c
No related branches found
No related tags found
No related merge requests found
package commands
import (
"sort"
"github.com/spf13/cobra"
"github.com/git-bug/git-bug/commands/execenv"
)
type commandOptions struct {
desc bool
}
func newCommandsCommand(env *execenv.Env) *cobra.Command {
options := commandOptions{}
cmd := &cobra.Command{
Use: "commands",
Short: "Display available commands.",
RunE: func(cmd *cobra.Command, args []string) error {
return runCommands(env, options)
},
}
flags := cmd.Flags()
flags.SortFlags = false
flags.BoolVarP(&options.desc, "pretty", "p", false,
"Output the command description as well as Markdown compatible comment",
)
return cmd
}
func runCommands(env *execenv.Env, opts commandOptions) error {
first := true
var allCmds []*cobra.Command
queue := []*cobra.Command{NewRootCommand()}
for len(queue) > 0 {
cmd := queue[0]
queue = queue[1:]
allCmds = append(allCmds, cmd)
queue = append(queue, cmd.Commands()...)
}
sort.Sort(commandSorterByName(allCmds))
for _, cmd := range allCmds {
if !first {
env.Out.Println()
}
first = false
if opts.desc {
env.Out.Printf("# %s\n", cmd.Short)
}
env.Out.Print(cmd.UseLine())
if opts.desc {
env.Out.Println()
}
}
if !opts.desc {
env.Out.Println()
}
return nil
}
type commandSorterByName []*cobra.Command
func (c commandSorterByName) Len() int { return len(c) }
func (c commandSorterByName) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
func (c commandSorterByName) Less(i, j int) bool { return c[i].CommandPath() < c[j].CommandPath() }
......@@ -75,7 +75,6 @@ the same git remote you are already using to collaborate with other people.
addCmdWithGroup(newPushCommand(env), remoteGroup)
addCmdWithGroup(bridgecmd.NewBridgeCommand(env), remoteGroup)
cmd.AddCommand(newCommandsCommand(env))
cmd.AddCommand(newVersionCommand(env))
cmd.AddCommand(newWipeCommand(env))
......
.nh
.TH "GIT-BUG" "1" "Apr 2019" "Generated from git-bug's source code" ""
.SH NAME
git-bug-commands - Display available commands.
.SH SYNOPSIS
\fBgit-bug commands [flags]\fP
.SH DESCRIPTION
Display available commands.
.SH OPTIONS
\fB-p\fP, \fB--pretty\fP[=false]
Output the command description as well as Markdown compatible comment
.PP
\fB-h\fP, \fB--help\fP[=false]
help for commands
.SH SEE ALSO
\fBgit-bug(1)\fP
......@@ -24,4 +24,4 @@ the same git remote you are already using to collaborate with other people.
.SH SEE ALSO
\fBgit-bug-bridge(1)\fP, \fBgit-bug-bug(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP, \fBgit-bug-wipe(1)\fP
\fBgit-bug-bridge(1)\fP, \fBgit-bug-bug(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP, \fBgit-bug-wipe(1)\fP
......@@ -26,7 +26,6 @@ git-bug [flags]
* [git-bug bridge](git-bug_bridge.md) - List bridges to other bug trackers
* [git-bug bug](git-bug_bug.md) - List bugs
* [git-bug commands](git-bug_commands.md) - Display available commands.
* [git-bug label](git-bug_label.md) - List valid labels
* [git-bug pull](git-bug_pull.md) - Pull updates from a git remote
* [git-bug push](git-bug_push.md) - Push updates to a git remote
......
## git-bug commands
Display available commands.
```
git-bug commands [flags]
```
### Options
```
-p, --pretty Output the command description as well as Markdown compatible comment
-h, --help help for commands
```
### SEE ALSO
* [git-bug](git-bug.md) - A bug tracker embedded in Git
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment