зеркало из https://github.com/mislav/hub.git
Switch `alias`, `ci-status`, `delete`, `fork` to new args parser
This commit is contained in:
Родитель
f0a1f617a5
Коммит
1e733219a7
|
@ -29,10 +29,7 @@ hub(1)
|
|||
`,
|
||||
}
|
||||
|
||||
var flagAliasScript bool
|
||||
|
||||
func init() {
|
||||
cmdAlias.Flag.BoolVarP(&flagAliasScript, "script", "s", false, "SCRIPT")
|
||||
CmdRunner.Use(cmdAlias)
|
||||
}
|
||||
|
||||
|
@ -44,6 +41,7 @@ func alias(command *Command, args *Args) {
|
|||
shell = os.Getenv("SHELL")
|
||||
}
|
||||
|
||||
flagAliasScript := args.Flag.Bool("-s")
|
||||
if shell == "" {
|
||||
cmd := "hub alias <shell>"
|
||||
if flagAliasScript {
|
||||
|
|
|
@ -34,12 +34,9 @@ hub-pull-request(1), hub(1)
|
|||
`,
|
||||
}
|
||||
|
||||
var flagCiStatusVerbose bool
|
||||
var severityList []string
|
||||
|
||||
func init() {
|
||||
cmdCiStatus.Flag.BoolVarP(&flagCiStatusVerbose, "verbose", "v", false, "VERBOSE")
|
||||
|
||||
CmdRunner.Use(cmdCiStatus)
|
||||
|
||||
severityList = []string{
|
||||
|
@ -109,7 +106,7 @@ func ciStatus(cmd *Command, args *Args) {
|
|||
exitCode = 3
|
||||
}
|
||||
|
||||
if flagCiStatusVerbose && len(response.Statuses) > 0 {
|
||||
if args.Flag.Bool("--verbose") && len(response.Statuses) > 0 {
|
||||
verboseFormat(response.Statuses)
|
||||
} else {
|
||||
if state != "" {
|
||||
|
|
|
@ -38,13 +38,7 @@ hub-init(1), hub(1)
|
|||
`,
|
||||
}
|
||||
|
||||
var (
|
||||
flagDeleteAssumeYes bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmdDelete.Flag.BoolVarP(&flagDeleteAssumeYes, "--yes", "y", false, "YES")
|
||||
|
||||
CmdRunner.Use(cmdDelete)
|
||||
}
|
||||
|
||||
|
@ -74,7 +68,7 @@ func deleteRepo(command *Command, args *Args) {
|
|||
project := github.NewProject(owner, repoName, host.Host)
|
||||
gh := github.NewClient(project.Host)
|
||||
|
||||
if !flagDeleteAssumeYes {
|
||||
if !args.Flag.Bool("--yes") {
|
||||
ui.Printf("Really delete repository '%s' (yes/N)? ", project)
|
||||
answer := ""
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
|
|
|
@ -38,18 +38,7 @@ hub-clone(1), hub(1)
|
|||
`,
|
||||
}
|
||||
|
||||
var (
|
||||
flagForkNoRemote bool
|
||||
|
||||
flagForkOrganization string
|
||||
flagForkRemoteName string
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmdFork.Flag.BoolVar(&flagForkNoRemote, "no-remote", false, "")
|
||||
cmdFork.Flag.StringVarP(&flagForkRemoteName, "remote-name", "", "", "REMOTE")
|
||||
cmdFork.Flag.StringVarP(&flagForkOrganization, "org", "", "", "ORGANIZATION")
|
||||
|
||||
CmdRunner.Use(cmdFork)
|
||||
}
|
||||
|
||||
|
@ -69,14 +58,14 @@ func fork(cmd *Command, args *Args) {
|
|||
|
||||
params := map[string]interface{}{}
|
||||
forkOwner := host.User
|
||||
if flagForkOrganization != "" {
|
||||
if flagForkOrganization := args.Flag.Value("--org"); flagForkOrganization != "" {
|
||||
forkOwner = flagForkOrganization
|
||||
params["organization"] = forkOwner
|
||||
}
|
||||
|
||||
forkProject := github.NewProject(forkOwner, project.Name, project.Host)
|
||||
var newRemoteName string
|
||||
if flagForkRemoteName != "" {
|
||||
if flagForkRemoteName := args.Flag.Value("--remote-name"); flagForkRemoteName != "" {
|
||||
newRemoteName = flagForkRemoteName
|
||||
} else {
|
||||
newRemoteName = forkProject.Owner
|
||||
|
@ -110,7 +99,7 @@ func fork(cmd *Command, args *Args) {
|
|||
}
|
||||
|
||||
args.NoForward()
|
||||
if !flagForkNoRemote {
|
||||
if !args.Flag.Bool("--no-remote") {
|
||||
|
||||
originURL := originRemote.URL.String()
|
||||
url := forkProject.GitURL("", "", true)
|
||||
|
|
Загрузка…
Ссылка в новой задаче