1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/jobob-gmfs

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
gmfs.go 1.2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
= Отправлено 13.08.2015 06:29 cc25e68
package main
import (
"bufio"
"fmt"
"gmfs/core"
"os"
"runtime"
"strconv"
"strings"
)
var helpText = `
gmfs - the notes helper
actions:
gmfs help
gmfs test
gmfs start
`
const config = "conf/config.json"
func main() {
if len(os.Args) == 1 {
help(0)
}
action := os.Args[1]
switch action {
case "help":
help(0)
case "test":
handleNew()
case "start":
core.StartServer(config)
default:
help(0)
}
}
func handleNew() {
ipt := acceptInput("Enter the start server , using CPU cores '0 .. ': ")
if ipt != "" {
cpucores, err := strconv.Atoi(ipt)
if err != nil {
panic(err)
}
fmt.Printf("using %d CPU cores\n", cpucores)
runtime.GOMAXPROCS(cpucores)
core.StartServer(config)
} else {
help(1)
}
}
/**
* 打印帮助信息
*/
func help(exit int) {
fmt.Println(helpText)
os.Exit(exit)
}
/**
* 读取命令行输入
*/
func acceptInput(question string) string {
reader := bufio.NewReader(os.Stdin)
var (
response string
err error
)
for response == "" {
fmt.Print(question)
response, err = reader.ReadString('\n')
if err != nil {
fmt.Println("Oops, what was that?")
os.Exit(1)
}
response = strings.TrimSpace(response)
}
return response
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/jobob-gmfs.git
git@api.gitlife.ru:oschina-mirror/jobob-gmfs.git
oschina-mirror
jobob-gmfs
jobob-gmfs
master