diff --git a/backup b/backup new file mode 100755 index 0000000..e8ebf09 --- /dev/null +++ b/backup @@ -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: + - ./ diff --git a/cmd/start.go b/cmd/start.go index c5eea0f..289cea1 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -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") } diff --git a/haunt b/haunt new file mode 100755 index 0000000..1987e0f Binary files /dev/null and b/haunt differ diff --git a/src/haunt/cli.go b/src/haunt/cli.go index 65ddfe7..92b095c 100644 --- a/src/haunt/cli.go +++ b/src/haunt/cli.go @@ -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 diff --git a/src/haunt/schema.go b/src/haunt/schema.go index 2e919f2..3eb7c1b 100644 --- a/src/haunt/schema.go +++ b/src/haunt/schema.go @@ -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{