Rename the binary.
authorOllivier Robert <roberto@keltia.net>
Mon, 10 Apr 2017 21:40:05 +0200
changeset 53 da5079cecc3c
parent 52 825b890aff85
child 54 f1dbc4f4dbe3
Rename the binary.
cmd/gondole-cli/main.go
cmd/gondole-cli/utils.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/gondole-cli/main.go	Mon Apr 10 21:40:05 2017 +0200
@@ -0,0 +1,49 @@
+package main
+
+import (
+	"github.com/keltia/gondole"
+	"github.com/urfave/cli"
+	"log"
+	"os"
+)
+
+var (
+	fVerbose bool
+    instance *gondole.Gondole
+	cnf      *gondole.Config
+)
+
+func Register(c *cli.Context) (err error) {
+
+    instance, err = gondole.NewApp("gondole-cli", nil, gondole.NoRedirect)
+	return err
+}
+
+func init() {
+	cli.VersionFlag = cli.BoolFlag{Name: "version, V"}
+
+	cli.VersionPrinter = func(c *cli.Context) {
+		log.Printf("API wrapper: %s Mastodon CLI: %s\n", c.App.Version, gondole.APIVersion)
+	}
+}
+
+func main() {
+
+	app := cli.NewApp()
+	app.Name = "gondole"
+	app.Usage = "Mastodon CLI interface"
+	app.Author = "Ollivier Robert <roberto@keltia.net>"
+	app.Version = gondole.APIVersion
+	//app.HideVersion = true
+
+	app.Before = Register
+
+	app.Flags = []cli.Flag{
+		cli.BoolFlag{
+			Name:        "verbose,v",
+			Usage:       "verbose mode",
+			Destination: &fVerbose,
+		},
+	}
+	app.Run(os.Args)
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/gondole-cli/utils.go	Mon Apr 10 21:40:05 2017 +0200
@@ -0,0 +1,11 @@
+package main
+
+import "github.com/urfave/cli"
+
+// ByAlphabet is for sorting
+type ByAlphabet []cli.Command
+
+func (a ByAlphabet) Len() int           { return len(a) }
+func (a ByAlphabet) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
+func (a ByAlphabet) Less(i, j int) bool { return a[i].Name < a[j].Name }
+