Initial Commit

Added some cli commands
This commit is contained in:
Roxie Gibson 2021-07-13 22:34:32 +01:00
commit 9e52e9f676
Signed by untrusted user: roxxers
GPG Key ID: 5D0140EDEE123F4D
3 changed files with 101 additions and 0 deletions

84
cmd/abra/main.go Normal file
View File

@ -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: "<host>",
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 <host>.",
ArgsUsage: "<host> [<user>] [<port>]",
Description: "[<user>], [<port>] 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: "<provider>",
HideHelp: true,
},
{
Name: "remove",
Aliases: []string{"rm"},
Usage: "Remove server <host>",
HideHelp: true,
},
{
Name: "init",
Usage: "Set up a server for Docker swarm",
HideHelp: true,
ArgsUsage: "<host>",
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 <host>"`,
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)
}
}

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module coopcloud.tech/abra
go 1.16
require github.com/urfave/cli/v2 v2.3.0

12
go.sum Normal file
View File

@ -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=