From f6493e0d872e8427069c50abbdb635fab6b5a4b2 Mon Sep 17 00:00:00 2001 From: Gary Kramlich Date: Thu, 18 Nov 2021 01:30:50 -0600 Subject: [PATCH] Initial scaffolding --- consts/consts.go | 6 ++++++ globals/globals.go | 5 +++++ go.mod | 7 +++++++ go.sum | 12 ++++++++++++ main.go | 37 +++++++++++++++++++++++++++++++++++++ version/cmd.go | 16 ++++++++++++++++ version/version.go | 3 +++ 7 files changed, 86 insertions(+) create mode 100644 consts/consts.go create mode 100644 globals/globals.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 version/cmd.go create mode 100644 version/version.go diff --git a/consts/consts.go b/consts/consts.go new file mode 100644 index 0000000..8299051 --- /dev/null +++ b/consts/consts.go @@ -0,0 +1,6 @@ +package consts + +const ( + Name = "mautrix-discord" + Description = "Discord-Matrix puppeting bridge" +) diff --git a/globals/globals.go b/globals/globals.go new file mode 100644 index 0000000..5f81767 --- /dev/null +++ b/globals/globals.go @@ -0,0 +1,5 @@ +package globals + +type Globals struct { + Config string `kong:"flag,name='config',short='c',env='CONFIG',help='The configuration file to use',default='config.yaml'"` +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..eb30d66 --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module gitlab.com/beeper/discord + +go 1.17 + +require github.com/alecthomas/kong v0.2.18 + +require github.com/pkg/errors v0.9.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ee76b12 --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +github.com/alecthomas/kong v0.2.18 h1:H05f55eRO5f9gusObxgjpqKtozJNvniqMTuOPnf+2SQ= +github.com/alecthomas/kong v0.2.18/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..8ac2f05 --- /dev/null +++ b/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "os" + + "github.com/alecthomas/kong" + + "gitlab.com/beeper/discord/consts" + "gitlab.com/beeper/discord/globals" + "gitlab.com/beeper/discord/version" +) + +var cli struct { + globals.Globals + + Version version.Cmd `kong:"cmd,help='Display the version and exit'"` +} + +func main() { + ctx := kong.Parse( + &cli, + kong.Name(consts.Name), + kong.Description(consts.Description), + kong.UsageOnError(), + kong.ConfigureHelp(kong.HelpOptions{ + Compact: true, + Summary: true, + }), + ) + + err := ctx.Run(&cli.Globals) + if err != nil { + fmt.Fprintf(os.Stderr, "error: %s\n", err) + os.Exit(1) + } +} diff --git a/version/cmd.go b/version/cmd.go new file mode 100644 index 0000000..8c19eb5 --- /dev/null +++ b/version/cmd.go @@ -0,0 +1,16 @@ +package version + +import ( + "fmt" + + "gitlab.com/beeper/discord/consts" + "gitlab.com/beeper/discord/globals" +) + +type Cmd struct{} + +func (c *Cmd) Run(g *globals.Globals) error { + fmt.Printf("%s %s\n", consts.Name, String) + + return nil +} diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..0aefad0 --- /dev/null +++ b/version/version.go @@ -0,0 +1,3 @@ +package version + +const String = "0.0.1"