2013-07-13 12:19:42 +04:00
|
|
|
package commands
|
|
|
|
|
|
|
|
var cmdSubmodule = &Command{
|
2013-07-20 10:00:45 +04:00
|
|
|
Run: submodule,
|
2013-07-13 12:19:42 +04:00
|
|
|
GitExtension: true,
|
2016-01-24 11:56:18 +03:00
|
|
|
Usage: "submodule add [-p] [<OPTIONS>] [<USER>/]<REPOSITORY> <DESTINATION>",
|
|
|
|
Long: `Add a git submodule for a GitHub repository.
|
|
|
|
|
|
|
|
## Examples:
|
|
|
|
$ hub submodule add jingweno/gh vendor/gh
|
|
|
|
> git submodule add git://github.com/jingweno/gh.git vendor/gh
|
2016-01-24 18:50:01 +03:00
|
|
|
|
|
|
|
## See also:
|
|
|
|
|
|
|
|
hub-remote(1), hub(1), git-submodule(1)
|
2016-01-24 11:56:18 +03:00
|
|
|
`,
|
2013-07-13 12:19:42 +04:00
|
|
|
}
|
|
|
|
|
2013-12-30 02:18:14 +04:00
|
|
|
func init() {
|
|
|
|
CmdRunner.Use(cmdSubmodule)
|
|
|
|
}
|
|
|
|
|
2013-07-13 12:19:42 +04:00
|
|
|
func submodule(command *Command, args *Args) {
|
|
|
|
if !args.IsParamsEmpty() {
|
|
|
|
transformSubmoduleArgs(args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func transformSubmoduleArgs(args *Args) {
|
2013-12-17 04:35:51 +04:00
|
|
|
var idx int
|
|
|
|
if idx = args.IndexOfParam("add"); idx == -1 {
|
2013-07-20 18:31:12 +04:00
|
|
|
return
|
2013-07-13 12:19:42 +04:00
|
|
|
}
|
2013-12-17 04:35:51 +04:00
|
|
|
args.RemoveParam(idx)
|
2013-07-20 18:31:12 +04:00
|
|
|
transformCloneArgs(args)
|
2013-12-17 04:35:51 +04:00
|
|
|
args.InsertParam(idx, "add")
|
2013-07-13 12:19:42 +04:00
|
|
|
}
|