cli/main.go

60 lines
1.1 KiB
Go

package main
import (
"fmt"
"os"
"git.t-juice.club/microfilm/cli/actions"
"github.com/urfave/cli/v2"
)
const Version string = "v0.1.0"
func main() {
app := cli.App{
Name: "mf-cli",
Version: Version,
Commands: []*cli.Command{
{
Name: "auth",
Usage: "Auth-related commands.",
Action: func(ctx *cli.Context) error {
return cli.ShowSubcommandHelp(ctx)
},
Subcommands: []*cli.Command{
{
Name: "login",
Usage: "Login to microfilm. Storing token.",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "claims",
Usage: "Print claims of received token.",
},
},
Action: actions.Login,
},
},
},
{
Name: "user",
Usage: "User-related commands.",
Action: func(ctx *cli.Context) error {
return cli.ShowSubcommandHelp(ctx)
},
Subcommands: []*cli.Command{
{
Name: "create",
Usage: "Create a new user.",
Action: actions.UserCreate,
},
},
},
},
Action: cli.ShowAppHelp,
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "Error: %s", err)
}
}