github.com/greenpau/go-identity@v1.1.6/cmd/authdbctl/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/urfave/cli/v2"
     6  	"os"
     7  
     8  	"github.com/greenpau/versioned"
     9  )
    10  
    11  var (
    12  	app        *versioned.PackageManager
    13  	appVersion string
    14  	gitBranch  string
    15  	gitCommit  string
    16  	buildUser  string
    17  	buildDate  string
    18  	sh         *cli.App
    19  )
    20  
    21  func init() {
    22  	app = versioned.NewPackageManager("authdbctl")
    23  	app.Description = "AuthDB management client"
    24  	app.Documentation = "https://github.com/greenpau/go-identity/"
    25  	app.SetVersion(appVersion, "1.0.0")
    26  	app.SetGitBranch(gitBranch, "")
    27  	app.SetGitCommit(gitCommit, "")
    28  	app.SetBuildUser(buildUser, "")
    29  	app.SetBuildDate(buildDate, "")
    30  
    31  	cli.VersionPrinter = func(c *cli.Context) {
    32  		fmt.Fprintf(os.Stdout, "%s\n", app.Banner())
    33  	}
    34  
    35  	sh = cli.NewApp()
    36  	sh.Name = app.Name
    37  	sh.Version = app.Version
    38  	sh.Usage = app.Description
    39  	sh.Description = app.Documentation
    40  	sh.HideHelp = false
    41  	sh.HideVersion = false
    42  	sh.Flags = append(sh.Flags, &cli.StringFlag{
    43  		Name:    "config",
    44  		Aliases: []string{"c"},
    45  		Usage:   "Sets path to configuration from `CONFIG_PATH` (default: ~/.config/authdbctl/config.json)",
    46  		EnvVars: []string{"AUTHDBCTL_CONFIG_PATH"},
    47  	})
    48  }
    49  
    50  func main() {
    51  	sh.Run(os.Args)
    52  }