Repository navigation
Expand file tree
/
Copy pathcli.rs
More file actions
69 lines (58 loc) · 1.94 KB
/
Copy pathcli.rs
File metadata and controls
69 lines (58 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::strategy::*;
use std::path::PathBuf;
use structopt::StructOpt;
/// Hard Link Deduplicator
#[derive(StructOpt, Debug)]
pub struct Config {
/// Files to process
#[structopt(name = "FILE")]
pub files: Vec<String>,
/// Files to cache
#[structopt(short = "-c", long = "cache", raw(number_of_values = "1"))]
pub caches: Vec<String>,
/// Cache file
#[structopt(short = "-C", long = "cache-path", parse(from_os_str))]
pub cache_path_opt: Option<PathBuf>,
/// Clear the cache file
#[structopt(long = "clear-cache")]
pub clear_cache: bool,
/// Recursively find the files in the provided paths
#[structopt(short = "r", long = "recursive")]
pub recursive: bool,
/// Don't modify anything on the disk
#[structopt(short = "n", long = "dry-run")]
pub dry_run: bool,
/// The linking strategy to use - either hardlink, symlink or reflink
#[structopt(short = "s", long = "strategy", default_value = "hardlink")]
pub strategy: Strategy,
/// Parallelism level
#[structopt(short = "j", long = "parallel")]
pub parallel: Option<usize>,
/// Log level
#[structopt(short = "l", long = "log-level", default_value = "info")]
pub log_level: log::Level,
/// Generate the completion code for this shell
#[structopt(long = "completion")]
pub completion: Option<structopt::clap::Shell>,
}
impl Config {
pub fn cache_path(self: &Self) -> PathBuf {
let path = if let Some(ref path) = self.cache_path_opt {
path.clone()
} else {
let mut path = app_dirs::app_dir(
app_dirs::AppDataType::UserCache,
&app_dirs::AppInfo {
name: "hld",
author: "glehmann",
},
"",
)
.unwrap();
path.push("digests");
path
};
debug!("cache path: {}", path.display());
path
}
}