File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 66 "fmt"
77 "strings"
88
9+ "github.com/atotto/clipboard"
910 "github.com/aws/aws-sdk-go-v2/service/ssm"
1011 "github.com/spf13/cobra"
1112)
@@ -26,6 +27,7 @@ var getCmd = &cobra.Command{
2627func runGetCmd (cmd * cobra.Command , args []string ) {
2728 path := fmt .Sprintf ("/%s" , stripSlash (args [0 ]))
2829 decrypt , _ := cmd .Flags ().GetBool ("decrypt" )
30+ copy , _ := cmd .Flags ().GetBool ("copy" )
2931
3032 client := ssm .NewFromConfig (awsConfig )
3133
@@ -43,11 +45,19 @@ func runGetCmd(cmd *cobra.Command, args []string) {
4345 val = strings .TrimSuffix (val , "\n " )
4446 }
4547
46- fmt .Println (val )
48+ if copy {
49+ if err := clipboard .WriteAll (val ); err != nil {
50+ panic (err )
51+ }
52+ fmt .Println ("Value copied to clipboard!" )
53+ } else {
54+ fmt .Println (val )
55+ }
4756}
4857
4958func init () {
5059 getCmd .Flags ().BoolP ("decrypt" , "d" , true , "decrypt \" SecureString\" value" )
60+ getCmd .Flags ().BoolP ("copy" , "c" , false , "copy to clipboard" )
5161
5262 rootCmd .AddCommand (getCmd )
5363}
Original file line number Diff line number Diff line change 44
55require (
66 github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
7+ github.com/atotto/clipboard v0.1.4
78 github.com/aws/aws-sdk-go-v2 v1.2.1
89 github.com/aws/aws-sdk-go-v2/config v1.1.2
910 github.com/aws/aws-sdk-go-v2/service/ssm v1.1.2
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
2222github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef /go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw =
2323github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ =
2424github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d /go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw =
25+ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4 =
26+ github.com/atotto/clipboard v0.1.4 /go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI =
2527github.com/aws/aws-sdk-go v1.34.28 /go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48 =
2628github.com/aws/aws-sdk-go-v2 v1.2.1 h1:055XAi+MtmhyYX161p+jWRibkCb9YpI2ymXZiW1dwVY =
2729github.com/aws/aws-sdk-go-v2 v1.2.1 /go.mod h1:hTQc/9pYq5bfFACIUY9tc/2SYWd9Vnmw+testmuQeRY =
You can’t perform that action at this time.
0 commit comments