2023-10-23 19:27:11 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"git.t-juice.club/microfilm/cli/actions"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
2023-10-23 19:28:49 +00:00
|
|
|
const Version string = "v0.1.0"
|
|
|
|
|
2023-10-23 19:27:11 +00:00
|
|
|
func main() {
|
|
|
|
app := cli.App{
|
2023-10-23 19:28:49 +00:00
|
|
|
Name: "mf-cli",
|
|
|
|
Version: Version,
|
2023-10-23 19:27:11 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|