File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/exercism/cli/config"
7
+ "github.com/spf13/viper"
8
+ )
9
+
3
10
const msgWelcomePleaseConfigure = `
4
11
5
12
Welcome to Exercism!
@@ -33,3 +40,18 @@ const msgMissingMetadata = `
33
40
Please see https://exercism.io/cli-v1-to-v2 for instructions on how to fix it.
34
41
35
42
`
43
+
44
+ // validateUserConfig validates the presense of required user config values
45
+ func validateUserConfig (cfg * viper.Viper ) error {
46
+ if cfg .GetString ("token" ) == "" {
47
+ return fmt .Errorf (
48
+ msgWelcomePleaseConfigure ,
49
+ config .SettingsURL (cfg .GetString ("apibaseurl" )),
50
+ BinaryName ,
51
+ )
52
+ }
53
+ if cfg .GetString ("workspace" ) == "" || cfg .GetString ("apibaseurl" ) == "" {
54
+ return fmt .Errorf (msgRerunConfigure , BinaryName )
55
+ }
56
+ return nil
57
+ }
You can’t perform that action at this time.
0 commit comments