From 8ab797897cf87ae6793423169f29914ff6feb635 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Fri, 23 Aug 2024 10:08:11 -0500 Subject: [PATCH 1/4] Request by chris to add positional args --- src/cmd/property.go | 20 ++++++++++++++++---- src/submodules/opslevel-go | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/cmd/property.go b/src/cmd/property.go index c196c4b8..ee8f4d8a 100644 --- a/src/cmd/property.go +++ b/src/cmd/property.go @@ -96,10 +96,12 @@ var listPropertyCmd = &cobra.Command{ } var assignPropertyCmd = &cobra.Command{ - Use: "property", - Aliases: []string{"prop"}, - Short: "Assign a Property", - Long: `Assign a Property to an Entity by Id or Alias`, + Use: "property", + Aliases: []string{"prop"}, + Short: "Assign a Property", + Long: `Assign a Property to an Entity by Id or Alias`, + Args: cobra.RangeArgs(0, 2), + ArgAliases: []string{"OWNER", "PROPERTY_DEFINITION"}, Example: fmt.Sprintf(` cat << EOF | opslevel assign property -f - %s @@ -107,6 +109,16 @@ EOF`, getYaml[opslevel.PropertyInput]()), Run: func(cmd *cobra.Command, args []string) { input, err := readResourceInput[opslevel.PropertyInput]() cobra.CheckErr(err) + + switch len(args) { + case 0: + case 1: + input.Owner = *opslevel.NewIdentifier(args[0]) + case 2: + input.Owner = *opslevel.NewIdentifier(args[0]) + input.Definition = *opslevel.NewIdentifier(args[1]) + } + newProperty, err := getClientGQL().PropertyAssign(*input) cobra.CheckErr(err) diff --git a/src/submodules/opslevel-go b/src/submodules/opslevel-go index 9386ff8b..122a4a1a 160000 --- a/src/submodules/opslevel-go +++ b/src/submodules/opslevel-go @@ -1 +1 @@ -Subproject commit 9386ff8b9906ec95637706ce90f158306793b05d +Subproject commit 122a4a1a4df5b2f4d818a3e0b7c2eca0c51a74c9 From abd77f7d1c8fa75af271597321a157f455e43115 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Fri, 23 Aug 2024 10:10:23 -0500 Subject: [PATCH 2/4] tuning --- src/cmd/property.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cmd/property.go b/src/cmd/property.go index ee8f4d8a..740eba24 100644 --- a/src/cmd/property.go +++ b/src/cmd/property.go @@ -96,13 +96,16 @@ var listPropertyCmd = &cobra.Command{ } var assignPropertyCmd = &cobra.Command{ - Use: "property", - Aliases: []string{"prop"}, - Short: "Assign a Property", - Long: `Assign a Property to an Entity by Id or Alias`, - Args: cobra.RangeArgs(0, 2), - ArgAliases: []string{"OWNER", "PROPERTY_DEFINITION"}, + Use: "property [OWNER] [PROPERTY_DEFINITION]", + Aliases: []string{"prop"}, + Short: "Assign a Property", + Long: `Assign a Property to an Entity by Id or Alias`, + Args: cobra.RangeArgs(0, 2), Example: fmt.Sprintf(` +cat << EOF | opslevel assign property my-service my-property -f - +value: example_value +EOF + cat << EOF | opslevel assign property -f - %s EOF`, getYaml[opslevel.PropertyInput]()), From 1502ad53f8ae994d5b9aaf9bc25d45bffa8ed500 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Fri, 23 Aug 2024 10:13:50 -0500 Subject: [PATCH 3/4] Add changie --- .changes/unreleased/Feature-20240823-101332.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changes/unreleased/Feature-20240823-101332.yaml diff --git a/.changes/unreleased/Feature-20240823-101332.yaml b/.changes/unreleased/Feature-20240823-101332.yaml new file mode 100644 index 00000000..15394559 --- /dev/null +++ b/.changes/unreleased/Feature-20240823-101332.yaml @@ -0,0 +1,4 @@ +kind: Feature +body: Add ability to specify the owner id or alias and the property definition id + or alias on the command line arguments of the `assign property` command +time: 2024-08-23T10:13:32.68659-05:00 From 9e25809b240e694703773e4695c4c30c36da5773 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 23 Aug 2024 10:16:31 -0500 Subject: [PATCH 4/4] Apply suggestions from code review --- src/cmd/property.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmd/property.go b/src/cmd/property.go index 740eba24..bab6ade3 100644 --- a/src/cmd/property.go +++ b/src/cmd/property.go @@ -114,7 +114,6 @@ EOF`, getYaml[opslevel.PropertyInput]()), cobra.CheckErr(err) switch len(args) { - case 0: case 1: input.Owner = *opslevel.NewIdentifier(args[0]) case 2: