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 diff --git a/src/cmd/property.go b/src/cmd/property.go index c196c4b8..bab6ade3 100644 --- a/src/cmd/property.go +++ b/src/cmd/property.go @@ -96,17 +96,31 @@ var listPropertyCmd = &cobra.Command{ } var assignPropertyCmd = &cobra.Command{ - Use: "property", + 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]()), Run: func(cmd *cobra.Command, args []string) { input, err := readResourceInput[opslevel.PropertyInput]() cobra.CheckErr(err) + + switch len(args) { + 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