refactoring: arrange CLI propoerties
This commit is contained in:
parent
9bc92338ca
commit
1060df80f6
87
realize.go
87
realize.go
@ -16,37 +16,32 @@ 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"
|
logs = "logs.log"
|
||||||
logs = "logs.log"
|
host = "localhost"
|
||||||
host = "localhost"
|
port = 5001
|
||||||
port = 5001
|
interval = 200
|
||||||
interval = 200
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var r realize
|
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:"-"`
|
Projects *[]watcher.Project `yaml:"projects" json:"projects"`
|
||||||
Projects *[]watcher.Project `yaml:"projects" json:"projects"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Realize struct initialization
|
// Realize struct initialization
|
||||||
func init() {
|
func init() {
|
||||||
r = realize{
|
r = realize{
|
||||||
Name: name,
|
Sync: make(chan string),
|
||||||
Version: version,
|
|
||||||
Description: description,
|
|
||||||
Sync: make(chan string),
|
|
||||||
Settings: settings.Settings{
|
Settings: settings.Settings{
|
||||||
Config: settings.Config{
|
Config: settings.Config{
|
||||||
Create: true,
|
Create: true,
|
||||||
@ -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."},
|
||||||
@ -159,10 +154,10 @@ 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."},
|
||||||
@ -187,10 +182,10 @@ 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 {
|
||||||
@ -880,10 +875,10 @@ 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: ""},
|
||||||
},
|
},
|
||||||
@ -898,10 +893,10 @@ 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())
|
||||||
},
|
},
|
||||||
@ -910,10 +905,10 @@ 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