File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "encoding/json"
45 "fmt"
56 "godemon/controllers"
7+ "godemon/models"
8+ "io/ioutil"
69 "os"
710 "os/exec"
811 "time"
@@ -36,8 +39,28 @@ func watch(fileordirPath string) error {
3639
3740func main () {
3841 doneChan := make (chan bool )
39- filepath := os .Args [1 ]
40- modOrFile := os .Args [2 ]
42+ cnf := os .Args [1 ]
43+ var filepath string
44+ var modOrFile string
45+ if cnf == "cmd" {
46+ filepath = os .Args [2 ]
47+ modOrFile = os .Args [3 ]
48+ } else if cnf == "cnf" {
49+ command := os .Args [2 ]
50+ jsonFile , _ := os .Open ("godemon-cnf.json" )
51+ byteValue , _ := ioutil .ReadAll (jsonFile )
52+ var commands models.Commands
53+ json .Unmarshal (byteValue , & commands )
54+ for i := 0 ; i < len (commands .Commands ); i ++ {
55+ if command == commands .Commands [i ].Name {
56+ fmt .Println (commands .Commands [i ].Path )
57+ fmt .Println (commands .Commands [i ].Option )
58+ filepath = commands .Commands [i ].Path
59+ modOrFile = commands .Commands [i ].Option
60+ }
61+ }
62+ jsonFile .Close ()
63+ }
4164 fmt .Println (filepath )
4265 for true {
4366 go func (doneChan chan bool ) {
Original file line number Diff line number Diff line change 1+ package models
2+
3+ type Command struct {
4+ Name string `json:"name"`
5+ Path string `json:"path"`
6+ Option string `json:"file"`
7+ }
8+
9+ type Commands struct {
10+ Commands []Command `json:"commands"`
11+ }
You can’t perform that action at this time.
0 commit comments