Пример #1
0
func main() {

	gh.Init()

	// Autocomplete commands
	var getCommands = []string{"issue", "org", "pr", "repo", "team", "user"}

	ghub := cli.NewApp()
	ghub.Name = "Ghub"
	ghub.Usage = "Command line utility for GitHub"
	ghub.Email = "*****@*****.**"
	ghub.Author = "Drew Flower"
	ghub.EnableBashCompletion = true
	ghub.Commands = []cli.Command{
		{
			Name:  "create",
			Usage: "Create [COMMAND] (user, repo, pr, etc)",
			Subcommands: []cli.Command{
				issue.Create,
				org.Create,
				pr.Create,
				repo.Create,
				team.Create,
				user.Create,
			},
		},
		{
			Name:  "delete",
			Usage: "Delete [COMMAND] (user, repo, pr, etc)",
			Subcommands: []cli.Command{
				issue.Delete,
				org.Delete,
				pr.Delete,
				repo.Delete,
				team.Delete,
				user.Delete,
			},
		},
		{
			Name:  "get",
			Usage: "Get    [COMMAND] (user, repo, pr, etc)",
			Subcommands: []cli.Command{
				issue.Get,
				org.Get,
				pr.Get,
				repo.Get,
				team.Get,
				user.Get,
			},
			BashComplete: util.Autocomplete(getCommands),
		},
		{
			Name:  "update",
			Usage: "Update [COMMAND] (user, repo, pr, etc)",
			Subcommands: []cli.Command{
				issue.Update,
				org.Update,
				pr.Update,
				repo.Update,
				team.Update,
				user.Update,
			},
		},
	}

	ghub.Run(os.Args)
}
Пример #2
0
	},
}

var getRepoCommands = []string{"issues", "prs"}
var Get cli.Command = cli.Command{
	Name:  "repo",
	Usage: "ghub repo [org]/[repo]",
	Subcommands: []cli.Command{
		GetRepoIssuesCmd,
		GetRepoPullRequestsCmd,
	},
	Action: func(c *cli.Context) {
		util.CheckCommandArgs(1, c)
		getRepo(c)
	},
	BashComplete: util.Autocomplete(getRepoCommands),
}

var Update cli.Command = cli.Command{
	Name:  "repo",
	Usage: "Update a repo (NOT IMPLEMENTED)",
	Action: func(c *cli.Context) {
		println("repo updated")
	},
}

var GetRepoIssuesCmd cli.Command = cli.Command{
	Name:  "issues",
	Usage: "Get all issues of a repo",
	Action: func(c *cli.Context) {
		util.CheckCommandArgs(1, c)