Skip to content
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

🐛 load flags via viper/cnquery providers #1508

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 4 additions & 6 deletions apps/cnspec/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ To manually configure a policy, use this:
$ cnspec scan local -f bundle.mql.yaml --incognito

`,
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRun: func(cmd *cobra.Command, _ []string) {
// Special handling for users that want to see what output options are
// available. We have to do this before printing the help because we
// don't have a target connection or provider.
Expand Down Expand Up @@ -131,18 +131,16 @@ To manually configure a policy, use this:

_ = viper.BindPFlag("json", cmd.Flags().Lookup("json"))
_ = viper.BindPFlag("output", cmd.Flags().Lookup("output"))
if err := viper.BindPFlag("output-target", cmd.Flags().Lookup("output-target")); err != nil {
return err
}

return nil
_ = viper.BindPFlag("output-target", cmd.Flags().Lookup("output-target"))
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return []string{"yml", "yaml", "json"}, cobra.ShellCompDirectiveFilterFileExt
}
return []string{}, cobra.ShellCompDirectiveNoFileComp
},
// we have to initialize an empty run so it shows up as a runnable command in --help
Run: func(cmd *cobra.Command, args []string) {},
}

var scanCmdRun = func(cmd *cobra.Command, runtime *providers.Runtime, cliRes *plugin.ParseCLIRes) {
Expand Down
1 change: 1 addition & 0 deletions test/cli/testdata/cnspec_scan.ct
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ To manually configure a policy, use this:
$ cnspec scan local -f bundle.mql.yaml --incognito

Usage:
cnspec scan [flags]
cnspec scan [command]

Available Commands:
Expand Down
Loading