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