Example #1
0
File: cat.go Project: 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)
}
Example #2
0
File: init.go Project: 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()
}
Example #3
0
File: ls.go Project: 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
}
Example #4
0
File: add.go Project: 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)
}
Example #5
0
File: rm.go Project: burke/rabit
func cmdRm(args *docopt.Args, rabitDir, rabitRemote string) error {
	repo := repo.New(rabitDir)
	name := args.String["<name>"]
	return repo.Rm(name)
}