/
copy.go
39 lines (35 loc) · 892 Bytes
/
copy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cmd
import (
"fmt"
"github.com/pinpt/esp/internal/common"
"github.com/spf13/cobra"
"os"
)
// cpCmd represents the cp command
var copyCmd = &cobra.Command{
Use: "copy [OPTIONS] SRC_SSM_PATH DEST_SSM_PATH",
Aliases: []string{"cp"},
Short: "Copy a SSM Param from its current path to a new SSM Path",
Long: "Copy SSM value from an existing path to a new path.\n",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
if args[0] == "" {
fmt.Errorf("source can not be empty")
os.Exit(1)
}
if args[1] == "" {
fmt.Errorf("destination can not be empty")
os.Exit(1)
}
cc := common.CopyCommand{
Source: args[0],
Destination: args[1],
}
c.Copy(cc)
},
Example: "esp cp /ssm/path/key /ssm/new/path/key",
}
func init() {
rootCmd.AddCommand(copyCmd)
// cpCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}