package main

import (
	"fmt"
	"os"

	"git.t-juice.club/torjus/gpaste/cmd/client/actions"
	"github.com/urfave/cli/v2"
)

var (
	version = "dev"
	commit  = "none"
	date    = "unknown"
)

func main() {
	cli.VersionFlag = &cli.BoolFlag{Name: "version"}

	app := cli.App{
		Name:    "gpaste",
		Version: fmt.Sprintf("gpaste %s-%s (%s)", version, commit, date),
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:  "config",
				Usage: "Path to config-file.",
			},
			&cli.StringFlag{
				Name:  "url",
				Usage: "Base url of gpaste server",
			},
		},
		Commands: []*cli.Command{
			{
				Name:      "upload",
				Usage:     "Upload file(s)",
				ArgsUsage: "FILE [FILE]...",
				Action:    actions.ActionUpload,
			},
			{
				Name:      "delete",
				Usage:     "Delete file(s)",
				ArgsUsage: "FILE [FILE]...",
				Action:    actions.ActionDelete,
			},
			{
				Name:      "login",
				Usage:     "Login to gpaste server",
				ArgsUsage: "USERNAME",
				Action:    actions.ActionLogin,
			},
			{
				Name:  "admin",
				Usage: "Admin related commands",
				Subcommands: []*cli.Command{
					{
						Name:      "create-user",
						Usage:     "Create a new user",
						ArgsUsage: "USERNAME",
						Action:    actions.ActionUserCreate,
					},
				},
			},
		},
	}

	_ = app.Run(os.Args)
}