Skip to content

Make --recursive flag a string input #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
6 changes: 5 additions & 1 deletion configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion util/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down