constant and colors removed

This commit is contained in:
alessio 2016-08-03 10:29:26 +02:00
parent 5d30bf55b1
commit 85e6f0028c
1 changed files with 16 additions and 28 deletions

44
main.go
View File

@ -2,27 +2,14 @@ package main
import ( import (
"os" "os"
"fmt"
"gopkg.in/urfave/cli.v2" "gopkg.in/urfave/cli.v2"
"github.com/tockins/realize/realize" "github.com/tockins/realize/realize"
"github.com/fatih/color"
) )
const(
name = "Realize"
version = "v1.0"
email = "pracchia@hastega.it"
//description = "Run and build your applications on file changes. Watch custom paths and specific extensions. Define additional commands and multiple projects"
description = "Run and build your applications on file changes."
author = "Alessio Pracchia"
)
var blue = color.New(color.FgBlue, color.Bold).SprintFunc()
var bluel = color.New(color.FgBlue).SprintFunc()
func main() { func main() {
app := realize.Init()
handle := func(err error) error{ handle := func(err error) error{
if err != nil { if err != nil {
return cli.Exit(err.Error(), 86) return cli.Exit(err.Error(), 86)
@ -31,20 +18,19 @@ func main() {
} }
header := func(){ header := func(){
fmt.Println(blue(name)+" - "+blue(version)) app.Information()
fmt.Println(bluel(description)+"\n")
} }
app := &cli.App{ cli := &cli.App{
Name: name, Name: app.Name,
Version: version, Version: app.Version,
Authors: []*cli.Author{ Authors: []*cli.Author{
&cli.Author{ &cli.Author{
Name: author, Name: app.Author,
Email: email, Email: app.Email,
}, },
}, },
Usage: description, Usage: app.Description,
Commands: []*cli.Command{ Commands: []*cli.Command{
{ {
Name: "run", Name: "run",
@ -65,8 +51,9 @@ func main() {
Aliases: []string{"s"}, Aliases: []string{"s"},
Usage: "Create the initial config", Usage: "Create the initial config",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: "Sample App"}, &cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: "Sample App", Usage: "Project name \t"},
&cli.StringFlag{Name: "main", Aliases: []string{"m"}, Value: "main.go"}, &cli.StringFlag{Name: "main", Aliases: []string{"m"}, Value: "main.go", Usage: "Project main file \t"},
&cli.StringFlag{Name: "base", Aliases: []string{"b"}, Value: "/", Usage: "Project base path \t"},
&cli.BoolFlag{Name: "build", Value: false}, &cli.BoolFlag{Name: "build", Value: false},
&cli.BoolFlag{Name: "run", Value: true}, &cli.BoolFlag{Name: "run", Value: true},
&cli.BoolFlag{Name: "bin", Value: true}, &cli.BoolFlag{Name: "bin", Value: true},
@ -86,8 +73,9 @@ func main() {
Aliases: []string{"a"}, Aliases: []string{"a"},
Usage: "Add another project", Usage: "Add another project",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: "Sample App"}, &cli.StringFlag{Name: "name", Aliases: []string{"n"}, Value: "Sample App", Usage: "Project name \t"},
&cli.StringFlag{Name: "main", Aliases: []string{"m"}, Value: "main.go"}, &cli.StringFlag{Name: "main", Aliases: []string{"m"}, Value: "main.go", Usage: "Project main file \t"},
&cli.StringFlag{Name: "base", Aliases: []string{"b"}, Value: "/", Usage: "Project base path \t"},
&cli.BoolFlag{Name: "build", Value: false}, &cli.BoolFlag{Name: "build", Value: false},
&cli.BoolFlag{Name: "run", Value: true}, &cli.BoolFlag{Name: "run", Value: true},
&cli.BoolFlag{Name: "bin", Value: true}, &cli.BoolFlag{Name: "bin", Value: true},
@ -135,5 +123,5 @@ func main() {
}, },
} }
app.Run(os.Args) cli.Run(os.Args)
} }