6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-05 07:23:46 +00:00

Make the URL scheme default to ssh instead of https and make it configurable

This commit is contained in:
Grzegorz Dlugoszewski
2020-09-02 03:14:01 +02:00
parent ccbee82f0b
commit 0d797d625a
5 changed files with 84 additions and 57 deletions

View File

@@ -27,6 +27,7 @@ var cmd = &cobra.Command{
func init() {
cmd.PersistentFlags().StringP(cfg.KeyBranch, "b", "", "Branch (or tag) to checkout after cloning.")
cmd.PersistentFlags().StringP(cfg.KeyDefaultHost, "t", cfg.Defaults[cfg.KeyDefaultHost], "Host to use when <REPO> doesn't have a specified host.")
cmd.PersistentFlags().StringP(cfg.KeyDefaultScheme, "c", cfg.Defaults[cfg.KeyDefaultScheme], "Scheme to use when <REPO> doesn't have a specified scheme.")
cmd.PersistentFlags().StringP(cfg.KeyDump, "d", "", "Path to a dump file listing repos to clone. Ignored when <REPO> argument is used.")
cmd.PersistentFlags().BoolP(cfg.KeySkipHost, "s", false, "Don't create a directory for host.")
cmd.PersistentFlags().StringP(cfg.KeyReposRoot, "r", cfg.Defaults[cfg.KeyReposRoot], "Path to repos root where repositories are cloned.")
@@ -35,6 +36,7 @@ func init() {
viper.BindPFlag(cfg.KeyBranch, cmd.PersistentFlags().Lookup(cfg.KeyBranch))
viper.BindPFlag(cfg.KeyDefaultHost, cmd.PersistentFlags().Lookup(cfg.KeyDefaultHost))
viper.BindPFlag(cfg.KeyDefaultScheme, cmd.PersistentFlags().Lookup(cfg.KeyDefaultScheme))
viper.BindPFlag(cfg.KeyDump, cmd.PersistentFlags().Lookup(cfg.KeyDump))
viper.BindPFlag(cfg.KeyReposRoot, cmd.PersistentFlags().Lookup(cfg.KeyReposRoot))
viper.BindPFlag(cfg.KeySkipHost, cmd.PersistentFlags().Lookup(cfg.KeySkipHost))
@@ -51,12 +53,13 @@ func run(cmd *cobra.Command, args []string) error {
cfg.Expand(cfg.KeyReposRoot)
config := &pkg.GetCfg{
Branch: viper.GetString(cfg.KeyBranch),
DefHost: viper.GetString(cfg.KeyDefaultHost),
Dump: viper.GetString(cfg.KeyDump),
SkipHost: viper.GetBool(cfg.KeySkipHost),
Root: viper.GetString(cfg.KeyReposRoot),
URL: url,
Branch: viper.GetString(cfg.KeyBranch),
DefHost: viper.GetString(cfg.KeyDefaultHost),
DefScheme: viper.GetString(cfg.KeyDefaultScheme),
Dump: viper.GetString(cfg.KeyDump),
SkipHost: viper.GetBool(cfg.KeySkipHost),
Root: viper.GetString(cfg.KeyReposRoot),
URL: url,
}
return pkg.Get(config)
}