From 9e52e9f676580f0f654be42beb46be680c7a8322 Mon Sep 17 00:00:00 2001 From: Roxie Gibson Date: Tue, 13 Jul 2021 22:34:32 +0100 Subject: [PATCH] Initial Commit Added some cli commands --- cmd/abra/main.go | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 5 +++ go.sum | 12 +++++++ 3 files changed, 101 insertions(+) create mode 100644 cmd/abra/main.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/cmd/abra/main.go b/cmd/abra/main.go new file mode 100644 index 00000000..8ae11b5e --- /dev/null +++ b/cmd/abra/main.go @@ -0,0 +1,84 @@ +package main + +import ( + "fmt" + "log" + "os" + + "github.com/urfave/cli/v2" +) + +func main() { + app := &cli.App{ + Name: "abra", + Usage: "The cooperative cloud utility belt 🎩🐇", + Version: "TBA", + Commands: []*cli.Command{ + { + Name: "server", + ArgsUsage: "", + Usage: "Interact with the servers hosting your Coop-Cloud apps", + Subcommands: []*cli.Command{ + { + Name: "list", + Aliases: []string{"ls"}, + Usage: "List locally-defined servers.", + ArgsUsage: " ", // Removes "[arguments]" from help. Empty str's are ignored + HideHelp: true, + }, + { + Name: "add", + Usage: "Add a server, reachable on .", + ArgsUsage: " [] []", + Description: "[], [] SSH connection details", + HideHelp: true, + }, + { + Name: "new", + Usage: "Creates a VPS from a provider in your terminal!", + Description: "Use a provider plugin to create an actual new server resource (VPS or otherwise) which can then be used to house a new Co-op Cloud installation.", + ArgsUsage: "", + HideHelp: true, + }, + { + Name: "remove", + Aliases: []string{"rm"}, + Usage: "Remove server ", + HideHelp: true, + }, + { + Name: "init", + Usage: "Set up a server for Docker swarm", + HideHelp: true, + ArgsUsage: "", + Description: `This initialisation explicitly chooses the "single host swarm" mode +which uses the default IPv4 address as the advertising address. This +can be re-configured later for more advanced use cases. + +POWERED BY + docker swarm init + docker network create ...`, + }, + { + Name: "apps", + Usage: `Alias for "abra app ls --server "`, + HideHelp: true, + ArgsUsage: " ", // Removes "[arguments]" from help. Empty str's are ignored + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "status", + Value: false, + }, + }, + }, + }, + Action: func(c *cli.Context) error { fmt.Println("server"); return nil }, + }, + }, + } + + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..c4e774eb --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module coopcloud.tech/abra + +go 1.16 + +require github.com/urfave/cli/v2 v2.3.0 diff --git a/go.sum b/go.sum new file mode 100644 index 00000000..012feeb5 --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=