-
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathrepo_clone.go
More file actions
40 lines (33 loc) · 1.21 KB
/
repo_clone.go
File metadata and controls
40 lines (33 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cmd
import (
"fmt"
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/completers/common/gh_completer/cmd/action"
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)
var repo_cloneCmd = &cobra.Command{
Use: "clone <repository> [<directory>] [-- <gitflags>...]",
Short: "Clone a repository locally",
GroupID: "Targeted commands",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(repo_cloneCmd).Standalone()
repo_cloneCmd.Flags().Bool("no-upstream", false, "Do not add an upstream remote when cloning a fork")
repo_cloneCmd.Flags().StringP("upstream-remote-name", "u", "", "Upstream remote name when cloning a fork")
repoCmd.AddCommand(repo_cloneCmd)
carapace.Gen(repo_cloneCmd).PositionalCompletion(
action.ActionOwnerRepositories(repo_cloneCmd),
carapace.ActionDirectories(),
)
carapace.Gen(repo_cloneCmd).DashAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
repo := ""
if args := repo_cloneCmd.Flags().Args(); len(args) > 0 {
repo = fmt.Sprintf("https://github.com/%v.git", args[0])
}
return bridge.ActionCarapaceBin("git", "clone", repo, "")
}),
)
}