refactoring: arrange CLI propoerties

This commit is contained in:
Kyoichiro Yamada 2017-04-13 22:53:58 +09:00
parent 9bc92338ca
commit 1060df80f6

View File

@ -16,9 +16,8 @@ import (
)
const (
name = "Realize"
version = "1.3"
description = "A Go build system with file watchers, output streams and live reload. Run, build and watch file changes with custom paths"
appVersion = "1.3"
config = "realize.yaml"
outputs = "outputs.log"
errs = "errors.log"
@ -33,7 +32,6 @@ var r realize
// Realize struct contains the general app informations
type realize struct {
settings.Settings `yaml:"settings,omitempty"`
Name, Description, Author, Email, Host, Version string `yaml:"-"`
Sync chan string `yaml:"-"`
Blueprint watcher.Blueprint `yaml:"-"`
Server server.Server `yaml:"-"`
@ -43,9 +41,6 @@ type realize struct {
// Realize struct initialization
func init() {
r = realize{
Name: name,
Version: version,
Description: description,
Sync: make(chan string),
Settings: settings.Settings{
Config: settings.Config{
@ -106,8 +101,8 @@ func handle(err error) error {
// Cli commands
func main() {
app := &cli.App{
Name: r.Name,
Version: r.Version,
Name: "Realize",
Version: appVersion,
Authors: []*cli.Author{
{
Name: "Alessio Pracchia",
@ -118,12 +113,12 @@ func main() {
Email: "conventi@hastega.it",
},
},
Usage: r.Description,
Description: "A Go build system with file watchers, output streams and live reload. Run, build and watch file changes with custom paths",
Commands: []*cli.Command{
{
Name: "run",
Aliases: []string{"r"},
Usage: "Run a toolchain on a project or a list of projects. If not exist a config file it creates a new one.",
Description: "Run a toolchain on a project or a list of projects. If not exist a config file it creates a new one",
Flags: []cli.Flag{
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
@ -162,7 +157,7 @@ func main() {
Name: "add",
Category: "Configuration",
Aliases: []string{"a"},
Usage: "Add a project to an existing config file or create a new one.",
Description: "Add a project to an existing config file or create a new one.",
Flags: []cli.Flag{
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
@ -190,7 +185,7 @@ func main() {
Name: "init",
Category: "Configuration",
Aliases: []string{"a"},
Usage: "Define a new config file with all options step by step",
Description: "Define a new config file with all options step by step",
Action: func(p *cli.Context) (actErr error) {
interact.Run(&interact.Interact{
Before: func(context interact.Context) error {
@ -883,7 +878,7 @@ func main() {
Name: "remove",
Category: "Configuration",
Aliases: []string{"r"},
Usage: "Remove a project from a realize configuration.",
Description: "Remove a project from a realize configuration.",
Flags: []cli.Flag{
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: ""},
},
@ -901,7 +896,7 @@ func main() {
Name: "list",
Category: "Configuration",
Aliases: []string{"l"},
Usage: "Print projects list.",
Description: "Print projects list.",
Action: func(p *cli.Context) error {
return handle(r.Blueprint.List())
},
@ -913,7 +908,7 @@ func main() {
Name: "clean",
Category: "Configuration",
Aliases: []string{"c"},
Usage: "Remove realize folder.",
Description: "Remove realize folder.",
Action: func(p *cli.Context) error {
handle(r.Settings.Remove())
fmt.Println(style.Yellow.Bold("[")+"REALIZE"+style.Yellow.Bold("]"), style.Green.Bold("Realize folder successfully removed."))