예제 #1
0
파일: dogo.go 프로젝트: kevinhuo88888/dogo
//start new monitor
func (d *Dogo) NewMonitor() {
	//fmt.Printf("%#v\n", d.SourceDir)

	if d.WorkingDir == "" {
		//log.Fatalf("[dogo] dogo.json (BuildCmd) error. \n")
		d.WorkingDir = console.WorkingDir
	}
	if len(d.SourceDir) == 0 {
		//log.Fatalf("[dogo] dogo.json (SourceDir) error. \n")
		d.SourceDir = append(d.SourceDir, console.WorkingDir)
	}
	if d.SourceExt == "" {
		//log.Fatalf("[dogo] dogo.json (SourceExt) error. \n")
		d.SourceExt = ".go|.c|.cpp|.h"
	}
	if d.BuildCmd == "" {
		//log.Fatalf("[dogo] dogo.json (BuildCmd) error. \n")
		d.BuildCmd = "go build ."
	}
	if d.RunCmd == "" {
		//log.Fatalf("[dogo] dogo.json (RunCmd) error. \n")
		d.RunCmd = filepath.Base(console.WorkingDir)
		if runtime.GOOS == "windows" {
			d.RunCmd += ".exe"
		}
	}

	// Append the current directory to the PATH for compatible linux.
	console.Setenv("PATH", console.Getenv("PATH")+string(os.PathListSeparator)+d.WorkingDir)

	console.Chdir(d.WorkingDir)
	fmt.Printf("[dogo] Working Directory:\n")
	fmt.Printf("       %s\n", d.WorkingDir)

	fmt.Printf("[dogo] Monitoring Directories:\n")
	for _, dir := range d.SourceDir {
		fmt.Printf("       %s\n", dir)
	}

	fmt.Printf("[dogo] File extends:\n")
	fmt.Printf("       %s\n", d.SourceExt)

	fmt.Printf("[dogo] Build command:\n")
	fmt.Printf("       %s\n", d.BuildCmd)

	fmt.Printf("[dogo] Run command:\n")
	fmt.Printf("       %s\n", d.RunCmd)

	d.Files = make(map[string]time.Time)
	d.InitFiles()

	//FIXME: add console support.

	//FIXME: moniting directories: add file, delete file.

	//FIXME: Multi commands.
}
예제 #2
0
파일: dogo.go 프로젝트: vanishs/dogo
//start new monitor
func (d *Dogo) NewMonitor() {
	if d.WorkingDir == "" {
		d.WorkingDir = console.WorkingDir
	}
	if len(d.SourceDir) == 0 {
		d.SourceDir = append(d.SourceDir, console.WorkingDir)
	}
	if d.SourceExt == nil || len(d.SourceExt) == 0 {
		d.SourceExt = []string{".c", ".cpp", ".go", ".h"}
	}
	if d.BuildCmd == "" {
		d.BuildCmd = "go build ."
	}
	if d.RunCmd == "" {
		d.RunCmd = filepath.Base(console.WorkingDir)
		if runtime.GOOS == "windows" {
			d.RunCmd += ".exe"
		}
	}

	// Append the current directory to the PATH for compatible linux.
	console.Setenv("PATH", console.Getenv("PATH")+string(os.PathListSeparator)+d.WorkingDir)

	console.Chdir(d.WorkingDir)
	fmt.Printf("[dogo] Working Directory:\n")
	fmt.Printf("       %s\n", d.WorkingDir)

	fmt.Printf("[dogo] Monitoring Directories:\n")
	for _, dir := range d.SourceDir {
		fmt.Printf("       %s\n", dir)
	}

	fmt.Printf("[dogo] File extends:\n")
	fmt.Printf("       %s\n", d.SourceExt)

	fmt.Printf("[dogo] Build command:\n")
	fmt.Printf("       %s\n", d.BuildCmd)

	fmt.Printf("[dogo] Run command:\n")
	fmt.Printf("       %s\n", d.RunCmd)

	d.Files = make(map[string]time.Time)
	d.InitFiles()

	//TODO: add console support.
	//TODO: Multi commands.
}