go fmt & update per feedback

This commit is contained in:
Matti R 2020-03-02 13:59:32 -05:00
parent b0f0de3dde
commit b6044120ef
No known key found for this signature in database
GPG Key ID: 9D8A57ADAA232E95
6 changed files with 24 additions and 24 deletions

View File

@ -30,25 +30,23 @@ var (
Name: "generate", Name: "generate",
Aliases: []string{"gen"}, Aliases: []string{"gen"},
Usage: "Generate a basic configuration", Usage: "Generate a basic configuration",
Action: genConfigAction, Action: genConfigAction,
} }
cmdConfigInteractive cli.Command = cli.Command{ cmdConfigInteractive cli.Command = cli.Command{
Name: "interactive", Name: "start",
Aliases: []string{"i"}, Usage: "Interactive configuration process",
Usage: "Interactive configuration process",
Action: interactiveConfigAction, Action: interactiveConfigAction,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "sections", Name: "sections",
Value: "server db app", Value: "server db app",
Usage: "Which sections of the configuration to go through (requires --config)\n" + Usage: "Which sections of the configuration to go through\n" +
"valid values are any combination of 'server', 'db' and 'app' \n" + "valid values of sections flag are any combination of 'server', 'db' and 'app' \n" +
"example: writefreely --config --sections \"db app\"", "example: writefreely config start --sections \"db app\"",
}, },
}, },
} }
) )
func genConfigAction(c *cli.Context) error { func genConfigAction(c *cli.Context) error {
@ -60,4 +58,4 @@ func interactiveConfigAction(c *cli.Context) error {
app := writefreely.NewApp(c.String("c")) app := writefreely.NewApp(c.String("c"))
writefreely.DoConfig(app, c.String("sections")) writefreely.DoConfig(app, c.String("sections"))
return nil return nil
} }

View File

@ -27,15 +27,15 @@ var (
} }
cmdDBInit cli.Command = cli.Command{ cmdDBInit cli.Command = cli.Command{
Name: "init", Name: "init",
Usage: "Initialize Database", Usage: "Initialize Database",
Action: initDBAction, Action: initDBAction,
} }
cmdDBMigrate cli.Command = cli.Command{ cmdDBMigrate cli.Command = cli.Command{
Name: "migrate", Name: "migrate",
Usage: "Migrate Database", Usage: "Migrate Database",
Action: migrateDBAction, Action: migrateDBAction,
} }
) )
@ -47,4 +47,4 @@ func initDBAction(c *cli.Context) error {
func migrateDBAction(c *cli.Context) error { func migrateDBAction(c *cli.Context) error {
app := writefreely.NewApp(c.String("c")) app := writefreely.NewApp(c.String("c"))
return writefreely.Migrate(app) return writefreely.Migrate(app)
} }

View File

@ -29,12 +29,11 @@ var (
Name: "generate", Name: "generate",
Aliases: []string{"gen"}, Aliases: []string{"gen"},
Usage: "Generate encryption and authentication keys", Usage: "Generate encryption and authentication keys",
Action: genKeysAction, Action: genKeysAction,
} }
) )
func genKeysAction(c *cli.Context) error { func genKeysAction(c *cli.Context) error {
app := writefreely.NewApp(c.String("c")) app := writefreely.NewApp(c.String("c"))
return writefreely.GenerateKeyFiles(app) return writefreely.GenerateKeyFiles(app)
} }

View File

@ -23,6 +23,9 @@ import (
) )
func main() { func main() {
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s\n", c.App.Version)
}
app := &cli.App{ app := &cli.App{
Name: "WriteFreely", Name: "WriteFreely",
Usage: "A beautifully pared-down blogging platform", Usage: "A beautifully pared-down blogging platform",

View File

@ -29,9 +29,9 @@ var (
} }
cmdAddUser cli.Command = cli.Command{ cmdAddUser cli.Command = cli.Command{
Name: "add", Name: "create",
Usage: "Add new user", Usage: "Add new user",
Aliases: []string{"a"}, Aliases: []string{"a", "add"},
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "admin", Name: "admin",

View File

@ -20,10 +20,10 @@ import (
var ( var (
cmdServe cli.Command = cli.Command{ cmdServe cli.Command = cli.Command{
Name: "serve", Name: "serve",
Aliases: []string{"web"}, Aliases: []string{"web"},
Usage: "Run web application", Usage: "Run web application",
Action: serveAction, Action: serveAction,
} }
) )
@ -46,4 +46,4 @@ func serveAction(c *cli.Context) error {
writefreely.Serve(app, r) writefreely.Serve(app, r)
return nil return nil
} }