Skip to content

Commit 483206e

Browse files
author
Katrina Owen
committed
Normalize user config validation in submit and download commands
1 parent 33cd3c0 commit 483206e

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

cmd/download.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ Download other people's solutions by providing the UUID.
5050

5151
func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error {
5252
usrCfg := cfg.UserViperConfig
53-
if usrCfg.GetString("token") == "" {
54-
return fmt.Errorf(msgWelcomePleaseConfigure, config.SettingsURL(usrCfg.GetString("apibaseurl")), BinaryName)
55-
}
56-
if usrCfg.GetString("workspace") == "" || usrCfg.GetString("apibaseurl") == "" {
57-
return fmt.Errorf(msgRerunConfigure, BinaryName)
53+
if err := validateUserConfig(usrCfg); err != nil {
54+
return err
5855
}
5956

6057
uuid, err := flags.GetString("uuid")

cmd/submit.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ var submitCmd = &cobra.Command{
5151
func runSubmit(cfg config.Config, flags *pflag.FlagSet, args []string) error {
5252
usrCfg := cfg.UserViperConfig
5353

54-
if usrCfg.GetString("token") == "" {
55-
return fmt.Errorf(msgWelcomePleaseConfigure, config.SettingsURL(usrCfg.GetString("apibaseurl")), BinaryName)
56-
}
57-
58-
if usrCfg.GetString("workspace") == "" {
59-
return fmt.Errorf(msgRerunConfigure, BinaryName)
54+
if err := validateUserConfig(usrCfg); err != nil {
55+
return err
6056
}
6157

6258
for i, arg := range args {

0 commit comments

Comments
 (0)