Skip to content

Commit a5230fb

Browse files
author
Quentin Perez
committed
_ips: add --detach flag
1 parent beb4383 commit a5230fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/cli/x_ips.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package cli
66

77
var cmdIPS = &Command{
88
Exec: runIPS,
9-
UsageLine: "_ips [--new|--attach|--delete] [IP_ID [SERVER_ID]]",
9+
UsageLine: "_ips [OPTIONS] [IP_ID [SERVER_ID]]",
1010

1111
Description: "Interacts with your IPs",
1212
Hidden: true,
@@ -17,19 +17,22 @@ var cmdIPS = &Command{
1717
$ scw _ips --new
1818
$ scw _ips --attach IP_ID SERVER_ID
1919
$ scw _ips --delete IP_ID
20+
$ scw _ips --detach IP_ID
2021
`,
2122
}
2223

2324
func init() {
2425
cmdIPS.Flag.BoolVar(&ipHelp, []string{"h", "-help"}, false, "Print usage")
2526
cmdIPS.Flag.BoolVar(&ipNew, []string{"n", "-new"}, false, "Add a new IP")
2627
cmdIPS.Flag.BoolVar(&ipAttach, []string{"a", "-attach"}, false, "Attach an IP to a server")
28+
cmdIPS.Flag.BoolVar(&ipDetach, []string{"-detach"}, false, "Detach an IP from a server")
2729
cmdIPS.Flag.StringVar(&ipDelete, []string{"d", "-delete"}, "", "Detele an IP")
2830
}
2931

3032
var ipHelp bool // -h, --help flag
3133
var ipNew bool // -n, --new flag
3234
var ipAttach bool // -a, --attach flag
35+
var ipDetach bool // --detach flag
3336
var ipDelete string // -d, --delete flag
3437

3538
func runIPS(cmd *Command, args []string) error {
@@ -53,6 +56,9 @@ func runIPS(cmd *Command, args []string) error {
5356
}
5457
return cmd.API.AttachIP(args[0], args[1])
5558
}
59+
if ipDetach {
60+
return cmd.API.DetachIP(args[0])
61+
}
5662
if len(args) == 1 {
5763
ip, err := cmd.API.GetIP(args[0])
5864
if err != nil {

0 commit comments

Comments
 (0)