package main import ( "log" "github.com/docopt/docopt-go" ) func main() { usage := `Seafile Recovery. Usage: seafile_recovery [--storage=] head seafile_recovery [--storage=] ls (--dir= | --file=) seafile_recovery [--storage=] cp (--dir= | --file=) seafile_recovery [--storage=] s3 (--dir= | --file=) seafile_recovery (-h | --help) Options: -h --help Show this screen --storage= Set Seafile storage path [default: ./storage] --dir= Seafile Directory ID, can be obtained from commits as RootID --file= Seafile File ID, can be obtained through ls ` config := new(configCollect) opts, err := docopt.ParseDoc(usage) if err != nil { log.Fatal(err) } opts.Bind(config) checkRootFolder(config.Storage) rexists := repoExistsIn(config.Storage, config.RepoId) if config.Head { if !rexists["commits"] { log.Fatal("No commits folder found for repo ",config.RepoId) } cmdHead(config) } else if config.Ls { if !rexists["fs"] { log.Fatal("No fs folder found for repo ",config.RepoId) } if len(config.DirId) > 0 { cmdLs(config) } else { cmdInfo(config) } } else if config.Cp { if !rexists["fs"] { log.Fatal("No fs folder found for repo ",config.RepoId) } if !rexists["blocks"] { log.Fatal("No blocks folder found for repo ",config.RepoId) } if len(config.DirId) > 0 { cmdCpDir(config) } else { cmdCpFile(config) } } else if config.S3 { if !rexists["fs"] { log.Fatal("No fs folder found for repo ",config.RepoId) } if !rexists["blocks"] { log.Fatal("No blocks folder found for repo ",config.RepoId) } if len(config.DirId) > 0 { cmdS3Dir(config) } else { cmdS3File(config) } } else { log.Fatal("This command is not implemented") } }