From be54accd097ff53bd5140ea262afe89bc10daa45 Mon Sep 17 00:00:00 2001 From: Navnit M S Date: Wed, 8 Jan 2025 23:23:18 +0530 Subject: [PATCH] Fix command flags --- cmd/cli/app/profile/status/status.go | 4 ---- cmd/cli/app/profile/status/status_get.go | 4 ++++ cmd/cli/app/profile/status/status_list.go | 8 ++++++++ docs/docs/ref/cli/minder_profile_status_get.md | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/cli/app/profile/status/status.go b/cmd/cli/app/profile/status/status.go index 69a241c7c8..8f1b6f259c 100644 --- a/cmd/cli/app/profile/status/status.go +++ b/cmd/cli/app/profile/status/status.go @@ -27,10 +27,6 @@ var profileStatusCmd = &cobra.Command{ func init() { profile.ProfileCmd.AddCommand(profileStatusCmd) // Flags - profileStatusCmd.PersistentFlags().StringP("name", "n", "", "Profile name to get profile status for") - profileStatusCmd.PersistentFlags().StringP("id", "i", "", "ID to get profile status for") profileStatusCmd.PersistentFlags().StringP("output", "o", app.Table, fmt.Sprintf("Output format (one of %s)", strings.Join(app.SupportedOutputFormats(), ","))) - // Required - profileStatusCmd.MarkFlagsOneRequired("id", "name") } diff --git a/cmd/cli/app/profile/status/status_get.go b/cmd/cli/app/profile/status/status_get.go index e075d5cf68..b200ec2e54 100644 --- a/cmd/cli/app/profile/status/status_get.go +++ b/cmd/cli/app/profile/status/status_get.go @@ -164,6 +164,10 @@ func init() { getCmd.Flags().StringP("entity", "e", "", "Entity ID to get profile status for") getCmd.Flags().StringP("entity-type", "t", "", fmt.Sprintf("the entity type to get profile status for (one of %s)", entities.KnownTypesCSV())) + getCmd.Flags().StringP("id", "i", "", "ID to get profile status for") + getCmd.Flags().StringP("name", "n", "", "Profile name to get profile status for") + + getCmd.MarkFlagsOneRequired("id", "name") // Required if err := getCmd.MarkFlagRequired("entity"); err != nil { getCmd.Printf("Error marking flag required: %s", err) diff --git a/cmd/cli/app/profile/status/status_list.go b/cmd/cli/app/profile/status/status_list.go index bfa17ad049..f9b017d193 100644 --- a/cmd/cli/app/profile/status/status_list.go +++ b/cmd/cli/app/profile/status/status_list.go @@ -6,6 +6,7 @@ package status import ( "context" "fmt" + "os" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -84,4 +85,11 @@ func init() { listCmd.Flags().BoolP("detailed", "d", false, "List all profile violations") listCmd.Flags().StringP("ruleType", "r", "", "Filter profile status list by rule type") listCmd.Flags().String("ruleName", "", "Filter profile status list by rule name") + + listCmd.Flags().StringP("name", "n", "", "Profile name to list status for") + + if err := listCmd.MarkFlagRequired("name"); err != nil { + listCmd.Printf("Error marking flag required: %s", err) + os.Exit(1) + } } diff --git a/docs/docs/ref/cli/minder_profile_status_get.md b/docs/docs/ref/cli/minder_profile_status_get.md index a04dcea0d7..d1e9a14913 100644 --- a/docs/docs/ref/cli/minder_profile_status_get.md +++ b/docs/docs/ref/cli/minder_profile_status_get.md @@ -16,6 +16,8 @@ minder profile status get [flags] ### Options ``` + -i, --id string ID to get profile status for + -n, --name string Profile name to get profile status for -e, --entity string Entity ID to get profile status for -t, --entity-type string the entity type to get profile status for (one of artifact, build, build_environment, pipeline_run, release, repository, task_run) -h, --help help for get