cli/main.go
2023-10-23 21:27:11 +02:00

57 lines
1.0 KiB
Go

package main
import (
"fmt"
"os"
"git.t-juice.club/microfilm/cli/actions"
"github.com/urfave/cli/v2"
)
func main() {
app := cli.App{
Name: "mf-cli",
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)
}
}