Skip to content

Commit 7bb7aed

Browse files
authored
Merge pull request #97 from arduino/per1234/recursive-flag-string
Make --recursive flag a string input
2 parents 63844cd + c260881 commit 7bb7aed

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

cli/cli.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Root() *cobra.Command {
3535
rootCommand.PersistentFlags().String("format", "text", "The output format can be {text|json}.")
3636
rootCommand.PersistentFlags().String("library-manager", "", "Configure the checks for libraries in the Arduino Library Manager index. Can be {submit|update|false}.\nsubmit: Also run additional checks required to pass before a library is accepted for inclusion in the index.\nupdate: Also run additional checks required to pass before new releases of a library already in the index are accepted.\nfalse: Don't run any Library Manager-specific checks.")
3737
rootCommand.PersistentFlags().String("project-type", "all", "Only check projects of the specified type and their subprojects. Can be {sketch|library|all}.")
38-
rootCommand.PersistentFlags().Bool("recursive", true, "Search path recursively for Arduino projects to check. Can be {true|false}.")
38+
rootCommand.PersistentFlags().String("recursive", "true", "Search path recursively for Arduino projects to check. Can be {true|false}.")
3939
rootCommand.PersistentFlags().String("report-file", "", "Save a report on the checks to this file.")
4040
rootCommand.PersistentFlags().BoolP("verbose", "v", false, "Show more information while running checks.")
4141
rootCommand.PersistentFlags().Bool("version", false, "Print version and timestamp of the build.")

configuration/configuration.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ func Initialize(flags *pflag.FlagSet, projectPaths []string) error {
8080
return fmt.Errorf("--project-type flag value %s not valid", superprojectTypeFilterString)
8181
}
8282

83-
recursive, _ = flags.GetBool("recursive")
83+
recursiveString, _ := flags.GetString("recursive")
84+
recursive, err = strconv.ParseBool(recursiveString)
85+
if err != nil {
86+
return fmt.Errorf("--recursive flag value %s not valid", recursiveString)
87+
}
8488

8589
reportFilePathString, _ := flags.GetString("report-file")
8690
reportFilePath = paths.New(reportFilePathString)

configuration/configuration_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ func TestInitializeProjectType(t *testing.T) {
160160
func TestInitializeRecursive(t *testing.T) {
161161
flags := test.ConfigurationFlags()
162162

163+
flags.Set("recursive", "foo")
164+
assert.Error(t, Initialize(flags, projectPaths))
165+
163166
flags.Set("recursive", "true")
164167
assert.Nil(t, Initialize(flags, projectPaths))
165168
assert.True(t, Recursive())

util/test/test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func ConfigurationFlags() *pflag.FlagSet {
2727
flags.String("log-format", "text", "")
2828
flags.String("log-level", "panic", "")
2929
flags.String("project-type", "all", "")
30-
flags.Bool("recursive", true, "")
30+
flags.String("recursive", "true", "")
3131
flags.String("report-file", "", "")
3232
flags.Bool("verbose", false, "")
3333
flags.Bool("version", false, "")

0 commit comments

Comments
 (0)