Initial scaffolding
This commit is contained in:
6
consts/consts.go
Normal file
6
consts/consts.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
Name = "mautrix-discord"
|
||||
Description = "Discord-Matrix puppeting bridge"
|
||||
)
|
||||
5
globals/globals.go
Normal file
5
globals/globals.go
Normal file
@@ -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'"`
|
||||
}
|
||||
7
go.mod
Normal file
7
go.mod
Normal file
@@ -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
|
||||
12
go.sum
Normal file
12
go.sum
Normal file
@@ -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=
|
||||
37
main.go
Normal file
37
main.go
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
16
version/cmd.go
Normal file
16
version/cmd.go
Normal file
@@ -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
|
||||
}
|
||||
3
version/version.go
Normal file
3
version/version.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package version
|
||||
|
||||
const String = "0.0.1"
|
||||
Reference in New Issue
Block a user