@@ -26,7 +26,6 @@ var submitCmd = &cobra.Command{
2626
2727 Call the command with the list of files you want to submit.
2828` ,
29- Args : cobra .MinimumNArgs (1 ),
3029 RunE : func (cmd * cobra.Command , args []string ) error {
3130 cfg := config .NewConfig ()
3231
@@ -45,6 +44,14 @@ var submitCmd = &cobra.Command{
4544 // Ignore error. If the file doesn't exist, that is fine.
4645 _ = v .ReadInConfig ()
4746
47+ if len (args ) == 0 {
48+ files , err := getExerciseSolutionFiles ("." )
49+ if err != nil {
50+ return err
51+ }
52+ args = files
53+ }
54+
4855 return runSubmit (cfg , cmd .Flags (), args )
4956 },
5057}
@@ -114,6 +121,23 @@ func runSubmit(cfg config.Config, flags *pflag.FlagSet, args []string) error {
114121 return nil
115122}
116123
124+ func getExerciseSolutionFiles (baseDir string ) ([]string , error ) {
125+ v := viper .New ()
126+ v .AddConfigPath (filepath .Join (baseDir , ".exercism" ))
127+ v .SetConfigName ("config" )
128+ v .SetConfigType ("json" )
129+ err := v .ReadInConfig ()
130+ if err != nil {
131+ return nil , errors .New ("no files to submit" )
132+ }
133+ solutionFiles := v .GetStringSlice ("files.solution" )
134+ if len (solutionFiles ) == 0 {
135+ return nil , errors .New ("no files to submit" )
136+ }
137+
138+ return solutionFiles , nil
139+ }
140+
117141type submitCmdContext struct {
118142 usrCfg * viper.Viper
119143 flags * pflag.FlagSet
0 commit comments