Пример #1
0
func _payload() {
	payload, err := neyo.BuildPayload("./")
	if err != nil {
		neyo.Log(neyo.ERROR, "Build payload error %s", err)
	}
	buf, err := json.MarshalIndent(payload, "", "  ")
	if err != nil {
		neyo.Log(neyo.ERROR, "%s", err)
	}
	fmt.Printf("Payload: \n%s\n ", string(buf))
}
Пример #2
0
func _config() {
	cnf, err := neyo.ReadConfig(".")
	if err != nil {
		neyo.Log(neyo.ERROR, "Read config error %s", err)
	}
	buf, err := json.MarshalIndent(cnf, "", "  ")
	if err != nil {
		neyo.Log(neyo.ERROR, "Marshal error %s", err)
	}
	fmt.Printf("Global config: \n%s\n", string(buf))
}
Пример #3
0
func get_editor() (editor string) {
	editor = os.Getenv("EDITOR")
	cnf, err := neyo.ReadConfig(".")
	if err != nil {
		neyo.Log(neyo.ERROR, "Read config error %s", err)
	} else if ed, ok := cnf["editor"].(string); ok {
		editor = ed
	}
	return
}
Пример #4
0
func _compile(args []string) {
	public := neyo.DEFAULT_PUBLIC_DIRETORY
	if len(args) == 2 {
		public = args[1]
	}
	err := neyo.Compile(public)
	if err != nil {
		neyo.Log(neyo.ERROR, "%s", err)
	}
}
Пример #5
0
func _pprof() {
	f, _ := os.OpenFile("neyo.pprof", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
	defer f.Close()
	pprof.StartCPUProfile(f)
	defer pprof.StopCPUProfile()
	for i := 0; i < 100; i++ {
		err := neyo.Compile(neyo.DEFAULT_PUBLIC_DIRETORY)
		if err != nil {
			neyo.Log(neyo.ERROR, "%s", err)
		}
	}
}
Пример #6
0
func edit_new_post(path string) {
	if editor := get_editor(); editor != "" {
		fmt.Printf("Are you edit page? (Yes/No)")
		var ask string
		if _, err := fmt.Scan(&ask); err == nil {
			if _ask := strings.ToLower(ask); _ask == "y" || _ask == "yes" {
				neyo.Log(neyo.INFO, "Edit %s\n", editor, path)
				cmd := exec.Command(editor, path)
				cmd.Stdin = os.Stdin
				cmd.Stdout = os.Stdout
				cmd.Stderr = os.Stderr
				if err := cmd.Start(); err == nil {
					if err := cmd.Wait(); err != nil {
						neyo.Log(neyo.ERROR, "%s", err)
					}
				} else {
					neyo.Log(neyo.ERROR, "%s", err)
				}
			}
		}
	}
}
Пример #7
0
func _http(args []string) {
	address := "127.0.0.1"
	public := neyo.DEFAULT_PUBLIC_DIRETORY

	if la := len(args); la < 2 {
		Usage()
	} else if la == 2 {
		address = args[1]
	} else if la == 3 {
		address, public = args[1], args[2]
	}
	neyo.Log(neyo.INFO, "Listen at %s", address)
	http.ListenAndServe(address, http.FileServer(http.Dir(public)))
}