2013-05-29 22:58:46 +04:00
|
|
|
package commands
|
2013-04-09 08:53:13 +04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2013-06-29 01:21:48 +04:00
|
|
|
"github.com/jingweno/gh/utils"
|
2013-04-09 08:53:13 +04:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
var cmdHelp = &Command{
|
|
|
|
Usage: "help [command]",
|
2013-05-24 18:25:50 +04:00
|
|
|
Short: "Show help",
|
2013-05-29 22:58:46 +04:00
|
|
|
Long: `Shows usage for a command.`,
|
2013-04-09 08:53:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdHelp.Run = runHelp // break init loop
|
2013-12-30 02:18:14 +04:00
|
|
|
|
|
|
|
CmdRunner.Use(cmdHelp)
|
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
|
|
|
}
|
2013-06-29 01:21:48 +04:00
|
|
|
|
2013-07-02 23:12:20 +04:00
|
|
|
if args.ParamsSize() > 1 {
|
2013-06-29 01:21:48 +04:00
|
|
|
utils.Check(fmt.Errorf("too many arguments"))
|
2013-04-09 08:53:13 +04:00
|
|
|
}
|
|
|
|
|
2013-12-30 02:18:14 +04:00
|
|
|
for _, cmd := range CmdRunner.All() {
|
2013-07-02 23:12:20 +04:00
|
|
|
if cmd.Name() == args.FirstParam() {
|
2013-05-29 22:58:46 +04:00
|
|
|
cmd.PrintUsage()
|
2013-06-29 01:21:48 +04:00
|
|
|
os.Exit(0)
|
2013-04-09 08:53:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-06 00:58:51 +04:00
|
|
|
fmt.Fprintf(os.Stderr, "Unknown help topic: %q. Run 'git help'.\n", args.FirstParam())
|
2013-04-09 08:53:13 +04:00
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
ci-status Show the CI status of a commit
|
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)
|
2013-07-06 00:58:51 +04:00
|
|
|
|
|
|
|
See 'git help <command>' for more information on a specific command.
|
2013-12-18 22:56:46 +04:00
|
|
|
Run 'git update' to update to the latest version of gh.
|
2013-07-06 00:58:51 +04:00
|
|
|
`
|
2013-04-09 08:53:13 +04:00
|
|
|
|
2013-06-29 01:21:48 +04:00
|
|
|
func printUsage() {
|
2013-07-06 00:58:51 +04:00
|
|
|
fmt.Print(helpText)
|
2013-04-09 08:53:13 +04:00
|
|
|
}
|