refactoring: arrange CLI propoerties
This commit is contained in:
parent
9bc92338ca
commit
1060df80f6
27
realize.go
27
realize.go
@ -16,9 +16,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
name = "Realize"
|
appVersion = "1.3"
|
||||||
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"
|
|
||||||
config = "realize.yaml"
|
config = "realize.yaml"
|
||||||
outputs = "outputs.log"
|
outputs = "outputs.log"
|
||||||
errs = "errors.log"
|
errs = "errors.log"
|
||||||
@ -33,7 +32,6 @@ var r realize
|
|||||||
// Realize struct contains the general app informations
|
// Realize struct contains the general app informations
|
||||||
type realize struct {
|
type realize struct {
|
||||||
settings.Settings `yaml:"settings,omitempty"`
|
settings.Settings `yaml:"settings,omitempty"`
|
||||||
Name, Description, Author, Email, Host, Version string `yaml:"-"`
|
|
||||||
Sync chan string `yaml:"-"`
|
Sync chan string `yaml:"-"`
|
||||||
Blueprint watcher.Blueprint `yaml:"-"`
|
Blueprint watcher.Blueprint `yaml:"-"`
|
||||||
Server server.Server `yaml:"-"`
|
Server server.Server `yaml:"-"`
|
||||||
@ -43,9 +41,6 @@ type realize struct {
|
|||||||
// Realize struct initialization
|
// Realize struct initialization
|
||||||
func init() {
|
func init() {
|
||||||
r = realize{
|
r = realize{
|
||||||
Name: name,
|
|
||||||
Version: version,
|
|
||||||
Description: description,
|
|
||||||
Sync: make(chan string),
|
Sync: make(chan string),
|
||||||
Settings: settings.Settings{
|
Settings: settings.Settings{
|
||||||
Config: settings.Config{
|
Config: settings.Config{
|
||||||
@ -106,8 +101,8 @@ func handle(err error) error {
|
|||||||
// Cli commands
|
// Cli commands
|
||||||
func main() {
|
func main() {
|
||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: r.Name,
|
Name: "Realize",
|
||||||
Version: r.Version,
|
Version: appVersion,
|
||||||
Authors: []*cli.Author{
|
Authors: []*cli.Author{
|
||||||
{
|
{
|
||||||
Name: "Alessio Pracchia",
|
Name: "Alessio Pracchia",
|
||||||
@ -118,12 +113,12 @@ func main() {
|
|||||||
Email: "conventi@hastega.it",
|
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{
|
Commands: []*cli.Command{
|
||||||
{
|
{
|
||||||
Name: "run",
|
Name: "run",
|
||||||
Aliases: []string{"r"},
|
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{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
|
&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."},
|
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
|
||||||
@ -162,7 +157,7 @@ func main() {
|
|||||||
Name: "add",
|
Name: "add",
|
||||||
Category: "Configuration",
|
Category: "Configuration",
|
||||||
Aliases: []string{"a"},
|
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{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "path", Aliases: []string{"p"}, Value: "", Usage: "Project base path."},
|
&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."},
|
&cli.BoolFlag{Name: "test", Aliases: []string{"t"}, Value: false, Usage: "Enable go test."},
|
||||||
@ -190,7 +185,7 @@ func main() {
|
|||||||
Name: "init",
|
Name: "init",
|
||||||
Category: "Configuration",
|
Category: "Configuration",
|
||||||
Aliases: []string{"a"},
|
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) {
|
Action: func(p *cli.Context) (actErr error) {
|
||||||
interact.Run(&interact.Interact{
|
interact.Run(&interact.Interact{
|
||||||
Before: func(context interact.Context) error {
|
Before: func(context interact.Context) error {
|
||||||
@ -883,7 +878,7 @@ func main() {
|
|||||||
Name: "remove",
|
Name: "remove",
|
||||||
Category: "Configuration",
|
Category: "Configuration",
|
||||||
Aliases: []string{"r"},
|
Aliases: []string{"r"},
|
||||||
Usage: "Remove a project from a realize configuration.",
|
Description: "Remove a project from a realize configuration.",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: ""},
|
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: ""},
|
||||||
},
|
},
|
||||||
@ -901,7 +896,7 @@ func main() {
|
|||||||
Name: "list",
|
Name: "list",
|
||||||
Category: "Configuration",
|
Category: "Configuration",
|
||||||
Aliases: []string{"l"},
|
Aliases: []string{"l"},
|
||||||
Usage: "Print projects list.",
|
Description: "Print projects list.",
|
||||||
Action: func(p *cli.Context) error {
|
Action: func(p *cli.Context) error {
|
||||||
return handle(r.Blueprint.List())
|
return handle(r.Blueprint.List())
|
||||||
},
|
},
|
||||||
@ -913,7 +908,7 @@ func main() {
|
|||||||
Name: "clean",
|
Name: "clean",
|
||||||
Category: "Configuration",
|
Category: "Configuration",
|
||||||
Aliases: []string{"c"},
|
Aliases: []string{"c"},
|
||||||
Usage: "Remove realize folder.",
|
Description: "Remove realize folder.",
|
||||||
Action: func(p *cli.Context) error {
|
Action: func(p *cli.Context) error {
|
||||||
handle(r.Settings.Remove())
|
handle(r.Settings.Remove())
|
||||||
fmt.Println(style.Yellow.Bold("[")+"REALIZE"+style.Yellow.Bold("]"), style.Green.Bold("Realize folder successfully removed."))
|
fmt.Println(style.Yellow.Bold("[")+"REALIZE"+style.Yellow.Bold("]"), style.Green.Bold("Realize folder successfully removed."))
|
||||||
|
Loading…
Reference in New Issue
Block a user