Use custom cli classes

This commit is contained in:
9seconds
2021-03-10 18:08:25 +03:00
parent 9aa56191f9
commit 94084674c0
4 changed files with 34 additions and 44 deletions
+8 -1
View File
@@ -6,7 +6,12 @@ import (
"github.com/9seconds/mtg/v2/mtglib"
)
func runGenerateSecret(cli *CLI) {
type cliCommandGenerateSecret struct {
HostName string `arg optional help:"Hostname to use for domain fronting. Default is '${domain_front}'." name:"hostname" default:"${domain_front}"` // nolint: lll, govet
Hex bool `help:"Print secret in hex encoding."`
}
func (c *cliCommandGenerateSecret) Run(cli *CLI) error { // nolint: unparam
secret := mtglib.GenerateSecret(cli.GenerateSecret.HostName)
if cli.GenerateSecret.Hex {
@@ -14,4 +19,6 @@ func runGenerateSecret(cli *CLI) {
} else {
fmt.Println(secret.Base64()) // nolint: forbidigo
}
return nil
}