Skip to content

Commit 20b04da

Browse files
chore: 🚚 move initial config fetcher to config package
1 parent 7310e1a commit 20b04da

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

cmd/root.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,7 @@ var rootCmd = &cobra.Command{
3535
logger.Debugf("Error in loading config file: ", err)
3636
logger.Info("Config file not found, creating a new one...")
3737

38-
cfg = config.Config{
39-
Username: "",
40-
Token: "",
41-
Platform: "github",
42-
Server: config.Server{
43-
Domain: "github.com",
44-
Protocol: "https",
45-
},
46-
IncludeRepos: []string{},
47-
ExcludeRepos: []string{},
48-
IncludeOrgs: []string{},
49-
ExcludeOrgs: []string{},
50-
IncludeForks: false,
51-
IncludeWiki: true,
52-
Workspace: "",
53-
Cron: "",
54-
BackupDir: config.GetBackupDir(backupDir),
55-
CloneType: "bare",
56-
}
38+
cfg = config.GetInitialConfig()
5739

5840
err = config.SaveConfig(cfg, cfgFile)
5941
if err != nil {

pkg/config/config.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,25 @@ func SaveConfig(config Config, cfgFile string) error {
110110

111111
return viper.WriteConfig()
112112
}
113+
114+
func GetInitialConfig() Config {
115+
return Config{
116+
Username: "",
117+
Token: "",
118+
Platform: "github",
119+
Server: Server{
120+
Domain: "github.com",
121+
Protocol: "https",
122+
},
123+
IncludeRepos: []string{},
124+
ExcludeRepos: []string{},
125+
IncludeOrgs: []string{},
126+
ExcludeOrgs: []string{},
127+
IncludeForks: false,
128+
IncludeWiki: true,
129+
Workspace: "",
130+
Cron: "",
131+
BackupDir: GetBackupDir(""),
132+
CloneType: "bare",
133+
}
134+
}

0 commit comments

Comments
 (0)