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() {
|
||||
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.Vet, "vet", "v", false, "Enable go vet")
|
||||
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.Server, "server", "s", false, "Start server")
|
||||
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.Build, "build", "b", false, "Enable go build")
|
||||
startCmd.Flags().BoolVarP(&startConfig.Run, "run", "r", false, "Enable go run")
|
||||
startCmd.Flags().BoolVarP(&startConfig.Install, "install", "i", true, "Enable go install")
|
||||
startCmd.Flags().BoolVarP(&startConfig.Build, "build", "b", true, "Enable go build")
|
||||
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.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}
|
||||
if _, err := os.Stat("main.go"); err == nil {
|
||||
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()),
|
||||
Path: Wdir(),
|
||||
Tools: Tools{
|
||||
Install: Tool{
|
||||
Status: true,
|
||||
},
|
||||
Build: Tool{
|
||||
Status: true,
|
||||
},
|
||||
Run: Tool{
|
||||
Status: true,
|
||||
},
|
||||
@ -113,13 +116,16 @@ func (r *Haunt) SetDefaults() {
|
||||
for _, dir := range subDirs {
|
||||
if dir.IsDir() {
|
||||
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(),
|
||||
Path: "cmd/" + dir.Name(),
|
||||
Tools: Tools{
|
||||
Install: Tool{
|
||||
Status: true,
|
||||
},
|
||||
Build: Tool{
|
||||
Status: true,
|
||||
},
|
||||
Run: Tool{
|
||||
Status: true,
|
||||
},
|
||||
@ -147,10 +153,10 @@ func (r *Haunt) Stop() error {
|
||||
|
||||
// Start haunt workflow
|
||||
func (r *Haunt) Start() error {
|
||||
if len(r.Schema.Projects) > 0 {
|
||||
if len(r.Projects) > 0 {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(len(r.Schema.Projects))
|
||||
for k := range r.Schema.Projects {
|
||||
wg.Add(len(r.Projects))
|
||||
for k := range r.Projects {
|
||||
r.Schema.Projects[k].exit = make(chan os.Signal, 1)
|
||||
signal.Notify(r.Schema.Projects[k].exit, os.Interrupt)
|
||||
r.Schema.Projects[k].parent = r
|
||||
|
@ -3,6 +3,7 @@ package haunt
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
||||
"github.com/abs3ntdev/haunt/src/config"
|
||||
@ -37,7 +38,10 @@ func (s *Schema) Remove(name string) error {
|
||||
// New create a project using cli fields
|
||||
func (s *Schema) New(flags config.Flags) Project {
|
||||
if flags.Name == "" {
|
||||
flags.Name = Wdir()
|
||||
flags.Name = filepath.Base(Wdir())
|
||||
}
|
||||
if flags.Path == "" {
|
||||
flags.Path = Wdir()
|
||||
}
|
||||
fmt.Println(flags.Name)
|
||||
project := Project{
|
||||
|
Loading…
Reference in New Issue
Block a user