From 2a2c0779cbde3452a3f39940adb834f347a2b3e1 Mon Sep 17 00:00:00 2001 From: Sig Date: Sat, 24 Feb 2024 11:05:22 -0800 Subject: [PATCH] fix aliases (#6) fix aliases --- cmd/runitcmd/apply.go | 5 +++-- cmd/runitcmd/create.go | 25 +++++++++++++++---------- cmd/runitcmd/export.go | 5 +++-- cmd/runitcmd/list.go | 5 +++-- cmd/runitcmd/main.go | 12 +++++++----- cmd/runitcmd/setup.go | 37 ++++++++++++++++++++++--------------- runit/create.go | 3 +-- 7 files changed, 54 insertions(+), 38 deletions(-) diff --git a/cmd/runitcmd/apply.go b/cmd/runitcmd/apply.go index 4060ece..c347530 100644 --- a/cmd/runitcmd/apply.go +++ b/cmd/runitcmd/apply.go @@ -14,8 +14,9 @@ func initApply(app *Application) *cli.Command { flags := []cli.Flag{ &cli.BoolFlag{ - Name: "restart, r", - Usage: "restart service after changes", + Name: "restart", + Aliases: []string{"r"}, + Usage: "restart service after changes", }, } diff --git a/cmd/runitcmd/create.go b/cmd/runitcmd/create.go index 21f569b..2e9f736 100644 --- a/cmd/runitcmd/create.go +++ b/cmd/runitcmd/create.go @@ -14,24 +14,29 @@ func initCreate(app *Application) *cli.Command { flags := []cli.Flag{ &cli.StringFlag{ - Name: "exec, e", - Usage: "execute command", + Name: "exec", + Aliases: []string{"e"}, + Usage: "execute command", }, &cli.StringFlag{ - Name: "log-dir, l", - Usage: "log to directory", + Name: "log-dir", + Aliases: []string{"l"}, + Usage: "log to directory", }, &cli.BoolFlag{ - Name: "disabled, d", - Usage: "create service but do not enable it", + Name: "disabled", + Aliases: []string{"d"}, + Usage: "create service but do not enable it", }, &cli.BoolFlag{ - Name: "force, f", - Usage: "force update the service if it already exists", + Name: "force", + Aliases: []string{"f"}, + Usage: "force update the service if it already exists", }, &cli.BoolFlag{ - Name: "restart, r", - Usage: "restart the service after creation if it already exists", + Name: "restart", + Aliases: []string{"r"}, + Usage: "restart the service after creation if it already exists", }, } diff --git a/cmd/runitcmd/export.go b/cmd/runitcmd/export.go index 8b223ec..7ec7531 100644 --- a/cmd/runitcmd/export.go +++ b/cmd/runitcmd/export.go @@ -12,8 +12,9 @@ func initExport(app *Application) *cli.Command { flags := []cli.Flag{ &cli.BoolFlag{ - Name: "forgiving, f", - Usage: "be forgiving and try to parse the runit files", + Name: "forgiving", + Aliases: []string{"f"}, + Usage: "be forgiving and try to parse the runit files", }, } diff --git a/cmd/runitcmd/list.go b/cmd/runitcmd/list.go index c0176a8..5f8945a 100644 --- a/cmd/runitcmd/list.go +++ b/cmd/runitcmd/list.go @@ -18,8 +18,9 @@ func initList(app *Application) *cli.Command { flags := []cli.Flag{ &cli.BoolFlag{ - Name: "all, a", - Usage: "list all services", + Name: "all", + Usage: "list all services", + Aliases: []string{"a"}, }, } diff --git a/cmd/runitcmd/main.go b/cmd/runitcmd/main.go index e6f5ec2..5f3f975 100644 --- a/cmd/runitcmd/main.go +++ b/cmd/runitcmd/main.go @@ -36,13 +36,15 @@ func main() { app.Flags = []cli.Flag{ &cli.StringFlag{ - Name: "config, c", - Usage: "override configuration file", + Name: "config", + Aliases: []string{"c"}, + Usage: "override configuration file", }, &cli.StringFlag{ - Name: "level, l", - Value: "WARN", - Usage: "change log level", + Name: "level", + Aliases: []string{"l"}, + Value: "WARN", + Usage: "change log level", }, &cli.StringFlag{ Name: "log-dir", diff --git a/cmd/runitcmd/setup.go b/cmd/runitcmd/setup.go index 439fa4f..71acb36 100644 --- a/cmd/runitcmd/setup.go +++ b/cmd/runitcmd/setup.go @@ -22,16 +22,19 @@ func initSetup(app *Application) *cli.Command { Usage: "service name", }, &cli.BoolFlag{ - Name: "verbose, v", - Usage: "be verbose", + Name: "verbose", + Aliases: []string{"v"}, + Usage: "be verbose", }, &cli.BoolFlag{ - Name: "enable, e", - Usage: "setup service and enable it", + Name: "enable", + Aliases: []string{"e"}, + Usage: "setup service and enable it", }, &cli.BoolFlag{ - Name: "disable, d", - Usage: "setup service but do not enable it", + Name: "disable", + Aliases: []string{"d"}, + Usage: "setup service but do not enable it", }, &cli.StringFlag{ Name: "run", @@ -43,24 +46,28 @@ func initSetup(app *Application) *cli.Command { Usage: "service log command", }, &cli.StringSliceFlag{ - Name: "script", - Usage: "additional lines to execute before run", + Name: "script", + Aliases: []string{"s"}, + Usage: "additional lines to execute before run", }, &cli.BoolFlag{ - Name: "restart, r", + Name: "restart", Usage: "restart service", }, &cli.IntFlag{ - Name: "uid, u", - Usage: "user id", + Name: "uid", + Aliases: []string{"u"}, + Usage: "user id", }, &cli.IntFlag{ - Name: "gid, g", - Usage: "group id", + Name: "gid", + Aliases: []string{"g"}, + Usage: "group id", }, &cli.StringFlag{ - Name: "template, t", - Usage: "service template to use (does nothing, legacy only)", + Name: "template", + Aliases: []string{"t"}, + Usage: "service template to use (does nothing, legacy only)", }, } diff --git a/runit/create.go b/runit/create.go index d5ef0e4..e2021c2 100644 --- a/runit/create.go +++ b/runit/create.go @@ -13,8 +13,7 @@ func DefaultCreateOptions() *CreateOptions { type CreateOptions struct { Force bool Restart bool - - Script []string + Script []string } func (opts *CreateOptions) WithScript(lines []string) *CreateOptions {