示例#1
0
文件: cat.go 项目: burke/rabit
func cmdCat(args *docopt.Args, rabitDir, rabitRemote string) error {
	repo := repo.New(rabitDir)

	name := args.String["<name>"]

	return repo.CatFile(name, os.Stdout)
}
示例#2
0
文件: init.go 项目: burke/rabit
func cmdInit(args *docopt.Args, rabitDir, rabitRemote string) error {
	if rabitDir == "" {
		return fmt.Errorf("RABIT_DIR must specify a path to an existing directory")
	}
	stat, err := os.Stat(rabitDir)
	if err != nil || !stat.IsDir() {
		return fmt.Errorf("RABIT_DIR must specify a path to an existing directory")
	}

	return repo.New(rabitDir).Init()
}
示例#3
0
文件: ls.go 项目: burke/rabit
func cmdLs(args *docopt.Args, rabitDir, rabitRemote string) error {
	repo := repo.New(rabitDir)
	names, err := repo.LsFiles()
	if err != nil {
		return err
	}
	for _, name := range names {
		fmt.Println(name)
	}
	return nil
}
示例#4
0
文件: add.go 项目: burke/rabit
func cmdAdd(args *docopt.Args, rabitDir, rabitRemote string) error {
	repo := repo.New(rabitDir)

	path := args.String["<path>"]
	name := args.String["<name>"]

	f, err := os.Open(path)
	if err != nil {
		return err
	}

	return repo.Add(f, name)
}
示例#5
0
文件: rm.go 项目: burke/rabit
func cmdRm(args *docopt.Args, rabitDir, rabitRemote string) error {
	repo := repo.New(rabitDir)
	name := args.String["<name>"]
	return repo.Rm(name)
}