Move cli to separate package

This commit is contained in:
9seconds
2021-03-11 05:50:04 +03:00
parent 1a02511afe
commit 6b28488fbd
7 changed files with 114 additions and 58 deletions
+26
View File
@@ -0,0 +1,26 @@
package cli
import (
"fmt"
"github.com/9seconds/mtg/v2/mtglib"
)
type GenerateSecret struct {
base
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 *GenerateSecret) Run(cli *CLI) error { // nolint: unparam
secret := mtglib.GenerateSecret(cli.GenerateSecret.HostName)
if cli.GenerateSecret.Hex {
fmt.Println(secret.Hex()) // nolint: forbidigo
} else {
fmt.Println(secret.Base64()) // nolint: forbidigo
}
return nil
}