From 5ee20771a823de7e50b251d6ddb859d4642d8a00 Mon Sep 17 00:00:00 2001 From: PiMaDaum Date: Sun, 5 Feb 2023 19:38:58 +0100 Subject: [PATCH] Define filter argument as persistent flag in list command --- cmd/list.go | 6 ++++++ resource/list.go | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index 90124b2..7e94658 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -19,6 +19,12 @@ var listCmd = &cobra.Command{ func init() { rootCmd.AddCommand(listCmd) listCmd.PersistentFlags().BoolP("json", "j", false, "Output JSON") + listCmd.PersistentFlags().String("filter", "", + "Define a CEl expression as filter for any list commands. In the expression, all available columns of subcommand can be used (see -c/--column).\n"+ + "See also CEl specifications under https://github.com/google/cel-spec.\n"+ + "Examples:\n"+ + "\t--filter '(Name == \"SomeName\" || matches(Name, \"RegExpr\")) && URI.startsWith(\"https://auth.\")'\n"+ + "\t--filter 'Username == \"User\" && CreatedTimestamp > timestamp(\"2022-06-10T00:00:00.000-00:00\")'") listCmd.AddCommand(resource.ResourceListCmd) listCmd.AddCommand(folder.FolderListCmd) listCmd.AddCommand(group.GroupListCmd) diff --git a/resource/list.go b/resource/list.go index 322b80c..a283d56 100644 --- a/resource/list.go +++ b/resource/list.go @@ -28,15 +28,8 @@ var ResourceListCmd = &cobra.Command{ func init() { ResourceListCmd.Flags().Bool("favorite", false, "Resources that are marked as favorite") ResourceListCmd.Flags().Bool("own", false, "Resources that are owned by me") - ResourceListCmd.Flags().String("filter", "", - "Define a CEl expression as filter for resources. In the expression, all available columns can be used (see -c/--column).\n"+ - "See also CEl specifications under https://github.com/google/cel-spec."+ - "\nExamples:\n\t--filter '(Name == \"SomeName\" || matches(Name, \"RegExpr\")) && URI.startsWith(\"https://auth.\")'\n"+ - "\t--filter 'Username == \"User\" && CreatedTimestamp > timestamp(\"2022-06-10T00:00:00.000-00:00\")'") - ResourceListCmd.Flags().StringP("group", "g", "", "Resources that are shared with group") ResourceListCmd.Flags().StringArrayP("folder", "f", []string{}, "Resources that are in folder") - ResourceListCmd.Flags().StringArrayP("column", "c", []string{"ID", "FolderParentID", "Name", "Username", "URI"}, "Columns to return, possible Columns:\nID, FolderParentID, Name, Username, URI, Password, Description, CreatedTimestamp, ModifiedTimestamp") }