M autojoin/cmd.go => autojoin/cmd.go +5 -5
@@ 3,7 3,7 @@ package autojoin
import (
"fmt"
- "github.com/rwxrob/cmdtab"
+ "github.com/rwxrob/cmdbox"
"git.hnitbjorg.xyz/~edwargix/axon/shared"
"maunium.net/go/mautrix"
@@ 11,12 11,12 @@ import (
)
func init() {
- x := cmdtab.New("autojoin")
- x.Summary = "wait for room invitations and automatically join"
+ cmd := cmdbox.Add("axon autojoin")
+ cmd.Summary = "wait for room invitations and automatically join"
- x.Method = func(args []string) error {
+ cmd.Method = func(args []string) error {
if len(args) != 0 {
- return x.UsageError()
+ return cmd.UsageError()
}
return autojoin()
}
M deletemsgs/cmd.go => deletemsgs/cmd.go +7 -7
@@ 5,33 5,33 @@ import (
"os"
"git.hnitbjorg.xyz/~edwargix/axon/shared"
- "github.com/rwxrob/cmdtab"
+ "github.com/rwxrob/cmdbox"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
)
func init() {
- x := cmdtab.New("deletemsgs")
- x.Summary = `delete the messages with the given types that were sent by us (or
+ cmd := cmdbox.Add("deletemsgs")
+ cmd.Summary = `delete the messages with the given types that were sent by us (or
everyone) to the given room`
- x.Usage = `[-a] <roomID> <type>+
+ cmd.Usage = `[-a] <roomID> <type>+
-a delete all messages of the given types in the room, not
just those that were sent by us
`
- x.Method = func(args []string) error {
+ cmd.Method = func(args []string) error {
all := false
if len(args) < 2 || args[0] == "-h" {
- return x.UsageError()
+ return cmd.UsageError()
}
if args[0] == "-a" {
all = true
args = args[1:]
}
if len(args) < 2 {
- return x.UsageError()
+ return cmd.UsageError()
}
roomID := id.RoomID(args[0])
types := args[1:]
M echo/cmd.go => echo/cmd.go +6 -6
@@ 4,20 4,20 @@ import (
"fmt"
"git.hnitbjorg.xyz/~edwargix/axon/shared"
- "github.com/rwxrob/cmdtab"
+ "github.com/rwxrob/cmdbox"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
)
func init() {
- x := cmdtab.New("echo")
- x.Summary = "print all events, optionally filtering for a specific room"
- x.Usage = "[<roomID>]"
+ cmd := cmdbox.Add("echo")
+ cmd.Summary = "print all events, optionally filtering for a specific room"
+ cmd.Usage = "[<roomID>]"
- x.Method = func(args []string) error {
+ cmd.Method = func(args []string) error {
if len(args) > 1 || (len(args) > 0 && args[0] == "-h") {
- return x.UsageError()
+ return cmd.UsageError()
}
var roomID *id.RoomID
if len(args) == 1 {
M go.mod => go.mod +1 -1
@@ 4,7 4,7 @@ go 1.16
require (
github.com/kyoh86/xdg v1.2.0
- github.com/rwxrob/cmdtab v0.10.2
+ github.com/rwxrob/cmdbox v0.5.0
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
golang.org/x/net v0.0.0-20210521195947-fe42d452be8f // indirect
golang.org/x/sys v0.0.0-20210521203332-0cec03c779c1 // indirect
M go.sum => go.sum +5 -3
@@ 30,8 30,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
-github.com/rwxrob/cmdtab v0.10.2 h1:DElMFAqlJcfXTiZUSgU/c2AHAdRbxpOYQdYLvMpjF3k=
-github.com/rwxrob/cmdtab v0.10.2/go.mod h1:AZ16dJkvySlkGy2PBZDcUcRdar+SLv7t1an8OOKkOag=
+github.com/rwxrob/cmdbox v0.5.0 h1:5wbZo1l+0yiFsr9ppD5HcmXbSXIhLcmaCJqKXtCFJdU=
+github.com/rwxrob/cmdbox v0.5.0/go.mod h1:OBRzTIUTlpGictLK7OuKJoF0SBJxA1/GdUwLDz0GcpA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ 68,13 68,15 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
maunium.net/go/maulogger/v2 v2.2.4/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.9.12 h1:iNsKOCyK/BqN6Q/7A1aLj1B0/lMbr81LIg+Lry1Vjuo=
maunium.net/go/mautrix v0.9.12/go.mod h1:7IzKfWvpQtN+W2Lzxc0rLvIxFM3ryKX6Ys3S/ZoWbg8=
M main.go => main.go +7 -6
@@ 4,14 4,15 @@ import (
_ "git.hnitbjorg.xyz/~edwargix/axon/autojoin"
_ "git.hnitbjorg.xyz/~edwargix/axon/deletemsgs"
_ "git.hnitbjorg.xyz/~edwargix/axon/echo"
- "github.com/rwxrob/cmdtab"
+ "github.com/rwxrob/cmdbox"
)
func main() {
- x := cmdtab.New("axon", "autojoin", "deletemsgs", "echo")
- x.Summary = "a set of simple utility programs for the Matrix Client-Server API"
- x.Usage = "<cmd>"
- x.Version = "v0.0.0"
+ cmd := cmdbox.Add("axon", "autojoin", "deletemsgs", "echo")
+ cmd.Summary = "a set of simple utility programs for the Matrix Client-Server API"
+ cmd.Usage = "<cmd>"
+ cmd.Version = "v0.0.0"
+ cmd.Add()
- cmdtab.Execute("axon")
+ cmdbox.Execute("axon")
}