github.com/scorpionis/hub@v2.2.1+incompatible/commands/submodule.go (about) 1 package commands 2 3 var cmdSubmodule = &Command{ 4 Run: submodule, 5 GitExtension: true, 6 Usage: "submodule add [-p] OPTIONS [USER/]REPOSITORY DIRECTORY", 7 Short: "Initialize, update or inspect submodules", 8 Long: `Submodule repository "git://github.com/USER/REPOSITORY.git" into 9 DIRECTORY as with git-submodule(1). When USER/ is omitted, 10 assumes your GitHub login. With -p, use private remote 11 "git@github.com:USER/REPOSITORY.git".`, 12 } 13 14 func init() { 15 CmdRunner.Use(cmdSubmodule) 16 } 17 18 /** 19 $ gh submodule add jingweno/gh vendor/gh 20 > git submodule add git://github.com/jingweno/gh.git vendor/gh 21 22 $ gh submodule add -p jingweno/gh vendor/gh 23 > git submodule add git@github.com:jingweno/gh.git vendor/gh 24 25 $ gh submodule add -b gh --name gh jingweno/gh vendor/gh 26 > git submodule add -b gh --name gh git://github.com/jingweno/gh.git vendor/gh 27 **/ 28 29 func submodule(command *Command, args *Args) { 30 if !args.IsParamsEmpty() { 31 transformSubmoduleArgs(args) 32 } 33 } 34 35 func transformSubmoduleArgs(args *Args) { 36 var idx int 37 if idx = args.IndexOfParam("add"); idx == -1 { 38 return 39 } 40 args.RemoveParam(idx) 41 transformCloneArgs(args) 42 args.InsertParam(idx, "add") 43 }