forked from toolshed/abra
refactor: break up cli pkg into nice small chunks
This commit is contained in:
28
cli/server/add.go
Normal file
28
cli/server/add.go
Normal file
@ -0,0 +1,28 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"coopcloud.tech/abra/client"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var serverAddCommand = &cli.Command{
|
||||
Name: "add",
|
||||
Usage: "Add a new server, reachable on <host>.",
|
||||
ArgsUsage: "<host> [<user>] [<port>]",
|
||||
Description: "[<user>], [<port>] SSH connection details",
|
||||
Action: func(c *cli.Context) error {
|
||||
arg_len := c.Args().Len()
|
||||
args := c.Args().Slice()
|
||||
if arg_len < 3 {
|
||||
args = append(args, make([]string, 3-arg_len)...)
|
||||
}
|
||||
if err := client.CreateContext(args[0], args[1], args[2]); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
fmt.Println(args[0])
|
||||
return nil
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user