fix: haunt start works
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
42922c97b2
commit
b71c2ec517
29
backup
Executable file
29
backup
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
settings:
|
||||||
|
files:
|
||||||
|
errors:
|
||||||
|
status: false
|
||||||
|
path: ""
|
||||||
|
name: .r.logs.log
|
||||||
|
legacy:
|
||||||
|
force: false
|
||||||
|
interval: 100ms
|
||||||
|
server:
|
||||||
|
status: true
|
||||||
|
open: false
|
||||||
|
port: 5002
|
||||||
|
host: ""
|
||||||
|
schema:
|
||||||
|
- name: haunt
|
||||||
|
path: /home/abs3nt/Gits/haunt
|
||||||
|
commands:
|
||||||
|
install:
|
||||||
|
status: true
|
||||||
|
build:
|
||||||
|
status: true
|
||||||
|
run:
|
||||||
|
status: true
|
||||||
|
watcher:
|
||||||
|
extensions:
|
||||||
|
- go
|
||||||
|
paths:
|
||||||
|
- ./
|
@ -23,16 +23,16 @@ var startCmd = &cobra.Command{
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(startCmd)
|
rootCmd.AddCommand(startCmd)
|
||||||
startCmd.Flags().StringVarP(&startConfig.Path, "path", "p", "./", "Project base path")
|
startCmd.Flags().StringVarP(&startConfig.Path, "path", "p", "", "Project base path")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Format, "fmt", "f", false, "Enable go fmt")
|
startCmd.Flags().BoolVarP(&startConfig.Format, "fmt", "f", false, "Enable go fmt")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Vet, "vet", "v", false, "Enable go vet")
|
startCmd.Flags().BoolVarP(&startConfig.Vet, "vet", "v", false, "Enable go vet")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Test, "test", "t", false, "Enable go test")
|
startCmd.Flags().BoolVarP(&startConfig.Test, "test", "t", false, "Enable go test")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Generate, "generate", "g", false, "Enable go generate")
|
startCmd.Flags().BoolVarP(&startConfig.Generate, "generate", "g", false, "Enable go generate")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Server, "server", "s", false, "Start server")
|
startCmd.Flags().BoolVarP(&startConfig.Server, "server", "s", false, "Start server")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Open, "open", "o", false, "Open into the default browser")
|
startCmd.Flags().BoolVarP(&startConfig.Open, "open", "o", false, "Open into the default browser")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Install, "install", "i", false, "Enable go install")
|
startCmd.Flags().BoolVarP(&startConfig.Install, "install", "i", true, "Enable go install")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Build, "build", "b", false, "Enable go build")
|
startCmd.Flags().BoolVarP(&startConfig.Build, "build", "b", true, "Enable go build")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Run, "run", "r", false, "Enable go run")
|
startCmd.Flags().BoolVarP(&startConfig.Run, "run", "r", true, "Enable go run")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.Legacy, "legacy", "l", false, "Legacy watch by polling instead fsnotify")
|
startCmd.Flags().BoolVarP(&startConfig.Legacy, "legacy", "l", false, "Legacy watch by polling instead fsnotify")
|
||||||
startCmd.Flags().BoolVarP(&startConfig.NoConfig, "no-config", "c", false, "Ignore existing config and doesn't create a new one")
|
startCmd.Flags().BoolVarP(&startConfig.NoConfig, "no-config", "c", false, "Ignore existing config and doesn't create a new one")
|
||||||
}
|
}
|
||||||
|
@ -86,13 +86,16 @@ func (r *Haunt) SetDefaults() {
|
|||||||
r.Settings.Files.Errors = Resource{Name: FileLog, Status: false}
|
r.Settings.Files.Errors = Resource{Name: FileLog, Status: false}
|
||||||
if _, err := os.Stat("main.go"); err == nil {
|
if _, err := os.Stat("main.go"); err == nil {
|
||||||
log.Println(r.Prefix(Green.Bold("Adding: " + filepath.Base(Wdir()))))
|
log.Println(r.Prefix(Green.Bold("Adding: " + filepath.Base(Wdir()))))
|
||||||
r.Schema.Projects = append(r.Schema.Projects, Project{
|
r.Projects = append(r.Projects, Project{
|
||||||
Name: filepath.Base(Wdir()),
|
Name: filepath.Base(Wdir()),
|
||||||
Path: Wdir(),
|
Path: Wdir(),
|
||||||
Tools: Tools{
|
Tools: Tools{
|
||||||
Install: Tool{
|
Install: Tool{
|
||||||
Status: true,
|
Status: true,
|
||||||
},
|
},
|
||||||
|
Build: Tool{
|
||||||
|
Status: true,
|
||||||
|
},
|
||||||
Run: Tool{
|
Run: Tool{
|
||||||
Status: true,
|
Status: true,
|
||||||
},
|
},
|
||||||
@ -113,13 +116,16 @@ func (r *Haunt) SetDefaults() {
|
|||||||
for _, dir := range subDirs {
|
for _, dir := range subDirs {
|
||||||
if dir.IsDir() {
|
if dir.IsDir() {
|
||||||
log.Println(r.Prefix(Green.Bold("Adding: " + dir.Name())))
|
log.Println(r.Prefix(Green.Bold("Adding: " + dir.Name())))
|
||||||
r.Schema.Projects = append(r.Schema.Projects, Project{
|
r.Projects = append(r.Projects, Project{
|
||||||
Name: dir.Name(),
|
Name: dir.Name(),
|
||||||
Path: "cmd/" + dir.Name(),
|
Path: "cmd/" + dir.Name(),
|
||||||
Tools: Tools{
|
Tools: Tools{
|
||||||
Install: Tool{
|
Install: Tool{
|
||||||
Status: true,
|
Status: true,
|
||||||
},
|
},
|
||||||
|
Build: Tool{
|
||||||
|
Status: true,
|
||||||
|
},
|
||||||
Run: Tool{
|
Run: Tool{
|
||||||
Status: true,
|
Status: true,
|
||||||
},
|
},
|
||||||
@ -147,10 +153,10 @@ func (r *Haunt) Stop() error {
|
|||||||
|
|
||||||
// Start haunt workflow
|
// Start haunt workflow
|
||||||
func (r *Haunt) Start() error {
|
func (r *Haunt) Start() error {
|
||||||
if len(r.Schema.Projects) > 0 {
|
if len(r.Projects) > 0 {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(len(r.Schema.Projects))
|
wg.Add(len(r.Projects))
|
||||||
for k := range r.Schema.Projects {
|
for k := range r.Projects {
|
||||||
r.Schema.Projects[k].exit = make(chan os.Signal, 1)
|
r.Schema.Projects[k].exit = make(chan os.Signal, 1)
|
||||||
signal.Notify(r.Schema.Projects[k].exit, os.Interrupt)
|
signal.Notify(r.Schema.Projects[k].exit, os.Interrupt)
|
||||||
r.Schema.Projects[k].parent = r
|
r.Schema.Projects[k].parent = r
|
||||||
|
@ -3,6 +3,7 @@ package haunt
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/abs3ntdev/haunt/src/config"
|
"github.com/abs3ntdev/haunt/src/config"
|
||||||
@ -37,7 +38,10 @@ func (s *Schema) Remove(name string) error {
|
|||||||
// New create a project using cli fields
|
// New create a project using cli fields
|
||||||
func (s *Schema) New(flags config.Flags) Project {
|
func (s *Schema) New(flags config.Flags) Project {
|
||||||
if flags.Name == "" {
|
if flags.Name == "" {
|
||||||
flags.Name = Wdir()
|
flags.Name = filepath.Base(Wdir())
|
||||||
|
}
|
||||||
|
if flags.Path == "" {
|
||||||
|
flags.Path = Wdir()
|
||||||
}
|
}
|
||||||
fmt.Println(flags.Name)
|
fmt.Println(flags.Name)
|
||||||
project := Project{
|
project := Project{
|
||||||
|
Loading…
Reference in New Issue
Block a user