func cmdCat(args *docopt.Args, rabitDir, rabitRemote string) error { repo := repo.New(rabitDir) name := args.String["<name>"] return repo.CatFile(name, os.Stdout) }
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() }
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 }
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) }
func cmdRm(args *docopt.Args, rabitDir, rabitRemote string) error { repo := repo.New(rabitDir) name := args.String["<name>"] return repo.Rm(name) }