@@ -20,8 +20,8 @@ var putCmd = &cobra.Command{
2020 Args : func (cmd * cobra.Command , args []string ) error {
2121 context , _ := cmd .Flags ().GetString ("context" )
2222
23- if context == "" && len (args ) < 2 {
24- return errors .New ("requires a path and a value " )
23+ if context == "" && len (args ) < 1 {
24+ return errors .New ("requires a path" )
2525 }
2626
2727 return nil
@@ -98,9 +98,24 @@ func runPutCmdContext(cmd *cobra.Command, args []string, ctx string) {
9898
9999func runPutCmd (cmd * cobra.Command , args []string ) {
100100 path := args [0 ]
101- value := args [1 ]
102101 overwrite , _ := cmd .Flags ().GetBool ("overwrite" )
103102 valueType , _ := cmd .Flags ().GetString ("type" )
103+ valueFlag , _ := cmd .Flags ().GetString ("value" )
104+
105+ value := ""
106+ if len (args ) > 1 {
107+ value = args [1 ]
108+ }
109+
110+ if value == "" {
111+ // try to use the flag
112+ if valueFlag == "" {
113+ fmt .Println (text .FgRed .Sprint ("Value argument or flag is required." ))
114+ os .Exit (1 )
115+ }
116+
117+ value = valueFlag
118+ }
104119
105120 client := ssm .NewFromConfig (awsConfig )
106121
@@ -127,6 +142,7 @@ func init() {
127142 putCmd .Flags ().BoolP ("overwrite" , "o" , false , "overwrite param if exists." )
128143 putCmd .Flags ().StringP ("type" , "t" , "SecureString" , "type of parameter." )
129144 putCmd .Flags ().StringP ("context" , "c" , "" , "context mode for setting many values." )
145+ putCmd .Flags ().StringP ("value" , "v" , "" , "value to store." )
130146
131147 rootCmd .AddCommand (putCmd )
132148}
0 commit comments