hub/commands/help.go

109 строки
3.3 KiB
Go
Исходник Обычный вид История

2013-05-29 22:58:46 +04:00
package commands
2013-04-09 08:53:13 +04:00
import (
"fmt"
"os"
"sort"
"strings"
2013-04-09 08:53:13 +04:00
)
var cmdHelp = &Command{
Usage: "help [command]",
Short: "Show help",
Long: `Shows usage for a command.`,
GitExtension: true,
2013-04-09 08:53:13 +04:00
}
func init() {
cmdHelp.Run = runHelp
CmdRunner.Use(cmdHelp, "--help")
2013-04-09 08:53:13 +04:00
}
2013-06-26 19:48:34 +04:00
func runHelp(cmd *Command, args *Args) {
2013-07-02 23:12:20 +04:00
if args.IsParamsEmpty() {
2013-07-02 22:56:45 +04:00
printUsage()
os.Exit(0)
2013-04-09 08:53:13 +04:00
}
command := args.FirstParam()
c := CmdRunner.Lookup(command)
if c != nil && !c.GitExtension {
c.PrintUsage()
os.Exit(0)
} else if c == nil {
if args.HasFlags("-a", "--all") {
args.After("echo", "\nhub custom commands\n")
args.After("echo", " ", strings.Join(customCommands(), " "))
2013-04-09 08:53:13 +04:00
}
}
}
func customCommands() []string {
cmds := []string{}
for n, c := range CmdRunner.All() {
if !c.GitExtension && !strings.HasPrefix(n, "--") {
cmds = append(cmds, n)
}
}
sort.Sort(sort.StringSlice(cmds))
return cmds
2013-04-09 08:53:13 +04:00
}
2013-07-06 00:58:51 +04:00
var helpText = `usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[-c name=value] [--help]
<command> [<args>]
2013-04-09 08:53:13 +04:00
2013-07-06 00:58:51 +04:00
Basic Commands:
init Create an empty git repository or reinitialize an existing one
add Add new or modified files to the staging area
rm Remove files from the working directory and staging area
mv Move or rename a file, a directory, or a symlink
status Show the status of the working directory and staging area
commit Record changes to the repository
2013-07-04 09:07:23 +04:00
2013-07-06 00:58:51 +04:00
History Commands:
log Show the commit history log
diff Show changes between commits, commit and working tree, etc
show Show information about commits, tags or files
2013-06-21 22:40:42 +04:00
2013-07-06 00:58:51 +04:00
Branching Commands:
branch List, create, or delete branches
checkout Switch the active branch to another branch
merge Join two or more development histories (branches) together
tag Create, list, delete, sign or verify a tag object
2013-06-18 01:09:47 +04:00
2013-07-06 00:58:51 +04:00
Remote Commands:
clone Clone a remote repository into a new directory
fetch Download data, tags and branches from a remote repository
pull Fetch from and merge with another repository or a local branch
push Upload data, tags and branches to a remote repository
remote View and manage a set of remote repositories
2013-04-09 08:53:13 +04:00
2013-07-06 00:58:51 +04:00
Advanced Commands:
reset Reset your staging area or working directory to another point
rebase Re-apply a series of patches in one branch onto another
bisect Find by binary search the change that introduced a bug
grep Print files with lines matching a pattern in your codebase
GitHub Commands:
pull-request Open a pull request on GitHub
fork Make a fork of a remote repository on GitHub and add as remote
create Create this repository on GitHub and add GitHub as origin
browse Open a GitHub page in the default browser
compare Open a compare page on GitHub
2013-12-31 07:59:34 +04:00
release List or create releases (beta)
2013-12-31 08:15:32 +04:00
issue List or create issues (beta)
2014-01-04 19:06:06 +04:00
ci-status Show the CI status of a commit
2013-07-06 00:58:51 +04:00
See 'git help <command>' for more information on a specific command.
`
2013-04-09 08:53:13 +04:00
func printUsage() {
2013-07-06 00:58:51 +04:00
fmt.Print(helpText)
2013-04-09 08:53:13 +04:00
}