use docopt::Docopt; use ::chunker::ChunkerType; use ::util::{ChecksumType, Compression, HashMethod}; static USAGE: &'static str = " Usage: zvault init [--bundle-size SIZE] [--chunker METHOD] [--chunk-size SIZE] [--compression COMPRESSION] zvault backup [--full] zvault restore [] zvault check [--full] zvault backups zvault info zvault list [--tree] zvault stats zvault bundles zvault algotest Options: --tree Print the whole (sub-)tree from the backup --full Whether to verify the repository by loading all bundles --bundle-size SIZE The target size of a full bundle in MiB [default: 25] --chunker METHOD The chunking algorithm to use [default: fastcdc] --chunk-size SIZE The target average chunk size in KiB [default: 8] --compression COMPRESSION The compression to use [default: brotli/3] "; #[derive(RustcDecodable, Debug)] pub struct DocoptArgs { pub cmd_init: bool, pub cmd_backup: bool, pub cmd_restore: bool, pub cmd_check: bool, pub cmd_backups: bool, pub cmd_info: bool, pub cmd_list: bool, pub cmd_stats: bool, pub cmd_bundles: bool, pub cmd_algotest: bool, pub cmd_stat: bool, pub arg_file: Option, pub arg_repo: Option, pub arg_path: Option, pub arg_src: Option, pub arg_dst: Option, pub arg_backup: Option, pub flag_full: bool, pub flag_bundle_size: usize, pub flag_chunker: String, pub flag_chunk_size: usize, pub flag_compression: String, pub flag_tree: bool } pub enum Arguments { Init { repo_path: String, bundle_size: usize, chunker: ChunkerType, chunk_size: usize, compresion: Compression }, Backup { repo_path: String, backup_name: String, src_path: String, full: bool }, Restore { repo_path: String, backup_name: String, inode: Option, dst_path: String }, Check { repo_path: String, backup_name: Option, inode: Option, full: bool }, List { repo_path: String, backup_name: Option, inode: Option }, Info { repo_path: String, backup_name: Option, inode: Option }, ListBundles { repo_path: String }, AlgoTest { file: String } } pub fn parse() -> DocoptArgs { Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit()) }