golint and gofmt
This commit is contained in:
parent
0be93d14c5
commit
6b2d101f31
|
@ -8,12 +8,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
app_name = "Realize"
|
||||
app_version = "v1.0"
|
||||
app_email = "pracchia@hastega.it"
|
||||
app_description = "Run, install or build your applications on file changes. Output preview and multi project support"
|
||||
app_author = "Alessio Pracchia"
|
||||
app_file = "realize.config.yaml"
|
||||
appName = "Realize"
|
||||
appVersion = "v1.0"
|
||||
appEmail = "pracchia@hastega.it"
|
||||
appDescription = "Run, install or build your applications on file changes. Output preview and multi project support"
|
||||
appAuthor = "Alessio Pracchia"
|
||||
appFile = "realize.config.yaml"
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
@ -23,40 +23,47 @@ var red = color.New(color.FgRed, color.Bold).SprintFunc()
|
|||
var blue = color.New(color.FgBlue, color.Bold).SprintFunc()
|
||||
var bluel = color.New(color.FgBlue).SprintFunc()
|
||||
|
||||
var watcher_ignores = []string{"vendor", "bin"}
|
||||
var watcher_exts = []string{".go"}
|
||||
var watcher_paths = []string{"/"}
|
||||
var watcherIgnores = []string{"vendor", "bin"}
|
||||
var watcherExts = []string{".go"}
|
||||
var watcherPaths = []string{"/"}
|
||||
|
||||
// App struct contains the informations about realize
|
||||
type App struct {
|
||||
Name, Version, Description, Author, Email string
|
||||
}
|
||||
|
||||
// Init is an instance of app with default values
|
||||
func Init() *App {
|
||||
return &App{
|
||||
Name: app_name,
|
||||
Version: app_version,
|
||||
Description: app_description,
|
||||
Author: app_author,
|
||||
Email: app_email,
|
||||
Name: appName,
|
||||
Version: appVersion,
|
||||
Description: appDescription,
|
||||
Author: appAuthor,
|
||||
Email: appEmail,
|
||||
}
|
||||
}
|
||||
|
||||
// Fail is a red message, generally used for errors
|
||||
func Fail(msg string) {
|
||||
fmt.Println(red(msg))
|
||||
}
|
||||
|
||||
// Success is a green message, generally used for feedback
|
||||
func Success(msg string) {
|
||||
fmt.Println(green(msg))
|
||||
}
|
||||
|
||||
// LogSuccess is a green log message, generally used for feedback
|
||||
func LogSuccess(msg string) {
|
||||
log.Println(green(msg))
|
||||
}
|
||||
|
||||
// LogFail is a red log message, generally used for errors
|
||||
func LogFail(msg string) {
|
||||
log.Println(red(msg))
|
||||
}
|
||||
|
||||
// Information print realize name and description
|
||||
func (app *App) Information() {
|
||||
fmt.Println(blue(app.Name) + " - " + blue(app.Version))
|
||||
fmt.Println(bluel(app.Description) + "\n")
|
||||
|
|
|
@ -62,7 +62,7 @@ func (h *Config) Clean() {
|
|||
|
||||
// Read, Check and remove duplicates from the config file
|
||||
func (h *Config) Read() error {
|
||||
file, err := ioutil.ReadFile(h.file);
|
||||
file, err := ioutil.ReadFile(h.file)
|
||||
if err == nil {
|
||||
if len(h.Projects) > 0 {
|
||||
err = yaml.Unmarshal(file, h)
|
||||
|
@ -88,7 +88,7 @@ func (h *Config) Write() error {
|
|||
// Create config yaml file
|
||||
func (h *Config) Create(params *cli.Context) error {
|
||||
if h.Read() != nil {
|
||||
err := h.Write();
|
||||
err := h.Write()
|
||||
if err != nil {
|
||||
os.Remove(h.file)
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ func (h *Config) Create(params *cli.Context) error {
|
|||
|
||||
// Add another project
|
||||
func (h *Config) Add(params *cli.Context) error {
|
||||
err := h.Read();
|
||||
err := h.Read()
|
||||
if err == nil {
|
||||
new := Project{
|
||||
Name: params.String("name"),
|
||||
|
@ -129,7 +129,7 @@ func (h *Config) Add(params *cli.Context) error {
|
|||
|
||||
// Remove a project in list
|
||||
func (h *Config) Remove(params *cli.Context) error {
|
||||
err := h.Read();
|
||||
err := h.Read()
|
||||
if err == nil {
|
||||
for key, val := range h.Projects {
|
||||
if params.String("name") == val.Name {
|
||||
|
@ -148,7 +148,7 @@ func (h *Config) Remove(params *cli.Context) error {
|
|||
|
||||
// List of projects
|
||||
func (h *Config) List() error {
|
||||
err := h.Read();
|
||||
err := h.Read()
|
||||
if err == nil {
|
||||
for _, val := range h.Projects {
|
||||
fmt.Println(green("|"), green(val.Name))
|
||||
|
|
|
@ -24,7 +24,7 @@ type Watcher struct {
|
|||
|
||||
// Watch method adds the given paths on the Watcher
|
||||
func (h *Config) Watch() error {
|
||||
err := h.Read();
|
||||
err := h.Read()
|
||||
if err == nil {
|
||||
// loop projects
|
||||
wg.Add(len(h.Projects))
|
||||
|
|
Loading…
Reference in New Issue