diff --git a/cli/cli.go b/cli/cli.go index dd4504d6e..a74ab8597 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -35,7 +35,7 @@ func Root() *cobra.Command { rootCommand.PersistentFlags().String("format", "text", "The output format can be {text|json}.") 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.") rootCommand.PersistentFlags().String("project-type", "all", "Only check projects of the specified type and their subprojects. Can be {sketch|library|all}.") - rootCommand.PersistentFlags().Bool("recursive", true, "Search path recursively for Arduino projects to check. Can be {true|false}.") + rootCommand.PersistentFlags().String("recursive", "true", "Search path recursively for Arduino projects to check. Can be {true|false}.") rootCommand.PersistentFlags().String("report-file", "", "Save a report on the checks to this file.") rootCommand.PersistentFlags().BoolP("verbose", "v", false, "Show more information while running checks.") rootCommand.PersistentFlags().Bool("version", false, "Print version and timestamp of the build.") diff --git a/configuration/configuration.go b/configuration/configuration.go index 63c471518..2e373a4a4 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -80,7 +80,11 @@ func Initialize(flags *pflag.FlagSet, projectPaths []string) error { return fmt.Errorf("--project-type flag value %s not valid", superprojectTypeFilterString) } - recursive, _ = flags.GetBool("recursive") + recursiveString, _ := flags.GetString("recursive") + recursive, err = strconv.ParseBool(recursiveString) + if err != nil { + return fmt.Errorf("--recursive flag value %s not valid", recursiveString) + } reportFilePathString, _ := flags.GetString("report-file") reportFilePath = paths.New(reportFilePathString) diff --git a/configuration/configuration_test.go b/configuration/configuration_test.go index 29e510ed6..9ea49f30b 100644 --- a/configuration/configuration_test.go +++ b/configuration/configuration_test.go @@ -160,6 +160,9 @@ func TestInitializeProjectType(t *testing.T) { func TestInitializeRecursive(t *testing.T) { flags := test.ConfigurationFlags() + flags.Set("recursive", "foo") + assert.Error(t, Initialize(flags, projectPaths)) + flags.Set("recursive", "true") assert.Nil(t, Initialize(flags, projectPaths)) assert.True(t, Recursive()) diff --git a/util/test/test.go b/util/test/test.go index f9179bae7..b5539992f 100644 --- a/util/test/test.go +++ b/util/test/test.go @@ -27,7 +27,7 @@ func ConfigurationFlags() *pflag.FlagSet { flags.String("log-format", "text", "") flags.String("log-level", "panic", "") flags.String("project-type", "all", "") - flags.Bool("recursive", true, "") + flags.String("recursive", "true", "") flags.String("report-file", "", "") flags.Bool("verbose", false, "") flags.Bool("version", false, "")