cmd/gondole/main.go
changeset 38 8343e5264a9b
parent 31 ef2bdbd3dab7
equal deleted inserted replaced
37:a0d3e7265cd2 38:8343e5264a9b
     1 package main
     1 package main
     2 
     2 
     3 import (
     3 import (
     4     "log"
     4 	"github.com/keltia/gondole"
     5     "github.com/keltia/gondole"
     5 	"github.com/urfave/cli"
     6     "github.com/urfave/cli"
     6 	"log"
     7     "os"
     7 	"os"
     8 )
     8 )
     9 
     9 
    10 var (
    10 var (
    11     fVerbose bool
    11 	fVerbose bool
       
    12     instance *gondole.Gondole
       
    13 	cnf      *gondole.Config
    12 )
    14 )
    13 
    15 
    14 func Register(c *cli.Context) error {
    16 func Register(c *cli.Context) (err error) {
    15 
    17 
    16     return nil
    18     instance, err = gondole.NewApp("gondole-cli", nil, gondole.NoRedirect)
       
    19 	return err
    17 }
    20 }
    18 
    21 
    19 func init() {
    22 func init() {
    20     cli.VersionFlag = cli.BoolFlag{Name: "version, V"}
    23 	cli.VersionFlag = cli.BoolFlag{Name: "version, V"}
    21 
    24 
    22     cli.VersionPrinter = func(c *cli.Context) {
    25 	cli.VersionPrinter = func(c *cli.Context) {
    23         log.Printf("API wrapper: %s Mastodon CLI: %s\n", c.App.Version, gondole.APIVersion)
    26 		log.Printf("API wrapper: %s Mastodon CLI: %s\n", c.App.Version, gondole.APIVersion)
    24     }
    27 	}
    25 }
    28 }
    26 
    29 
    27 func main() {
    30 func main() {
    28     app := cli.NewApp()
       
    29     app.Name = "gondole"
       
    30     app.Usage = "Mastodon CLI interface"
       
    31     app.Author = "Ollivier Robert <roberto@keltia.net>"
       
    32     app.Version = gondole.APIVersion
       
    33     //app.HideVersion = true
       
    34 
    31 
    35     app.Before = Register
    32 	app := cli.NewApp()
       
    33 	app.Name = "gondole"
       
    34 	app.Usage = "Mastodon CLI interface"
       
    35 	app.Author = "Ollivier Robert <roberto@keltia.net>"
       
    36 	app.Version = gondole.APIVersion
       
    37 	//app.HideVersion = true
    36 
    38 
    37     app.Flags = []cli.Flag{
    39 	app.Before = Register
    38         cli.BoolFlag{
    40 
    39             Name:        "verbose,v",
    41 	app.Flags = []cli.Flag{
    40             Usage:       "verbose mode",
    42 		cli.BoolFlag{
    41             Destination: &fVerbose,
    43 			Name:        "verbose,v",
    42         },
    44 			Usage:       "verbose mode",
    43     }
    45 			Destination: &fVerbose,
    44     app.Run(os.Args)
    46 		},
       
    47 	}
       
    48 	app.Run(os.Args)
    45 }
    49 }