Skip to content

Commit

Permalink
Add check example
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome committed Jun 19, 2023
1 parent c1f8591 commit 0503e67
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
14 changes: 14 additions & 0 deletions crates/rustic_core/examples/check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! `check` example
use rustic_core::{CheckOpts, NoProgressBars, Repository, RepositoryOptions};

fn main() {
let opts = CheckOpts::default();
let progress = NoProgressBars {};

let mut repo_opts = RepositoryOptions::default();
repo_opts.repository = Some("/tmp/repo".to_string());
repo_opts.password = Some("test".to_string());
let repo = Repository::new(&repo_opts).unwrap().open().unwrap();

repo.check(opts, &progress).unwrap()
}
6 changes: 3 additions & 3 deletions crates/rustic_core/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ use crate::{

/// `check` subcommand
#[cfg_attr(feature = "clap", derive(clap::Parser))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Default)]
pub struct CheckOpts {
/// Don't verify the data saved in the cache
#[cfg_attr(feature = "clap", clap(long, conflicts_with = "no_cache"))]
trust_cache: bool,
pub trust_cache: bool,

/// Read all data blobs
#[cfg_attr(feature = "clap", clap(long))]
read_data: bool,
pub read_data: bool,
}

impl CheckOpts {
Expand Down
16 changes: 8 additions & 8 deletions crates/rustic_core/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ pub struct RepositoryOptions {
feature = "clap",
clap(short, long, global = true, alias = "repo", env = "RUSTIC_REPOSITORY")
)]
repository: Option<String>,
pub repository: Option<String>,

/// Repository to use as hot storage
#[cfg_attr(
feature = "clap",
clap(long, global = true, alias = "repository_hot", env = "RUSTIC_REPO_HOT")
)]
repo_hot: Option<String>,
pub repo_hot: Option<String>,

/// Password of the repository - WARNING: Using --password can reveal the password in the process list!
#[cfg_attr(feature = "clap", clap(long, global = true, env = "RUSTIC_PASSWORD"))]
// TODO: use `secrecy` library
password: Option<String>,
pub password: Option<String>,

/// File to read the password from
#[cfg_attr(
Expand All @@ -104,7 +104,7 @@ pub struct RepositoryOptions {
conflicts_with = "password"
)
)]
password_file: Option<PathBuf>,
pub password_file: Option<PathBuf>,

/// Command to read the password from
#[cfg_attr(feature = "clap", clap(
Expand All @@ -113,12 +113,12 @@ pub struct RepositoryOptions {
env = "RUSTIC_PASSWORD_COMMAND",
conflicts_with_all = &["password", "password_file"],
))]
password_command: Option<String>,
pub password_command: Option<String>,

/// Don't use a cache.
#[cfg_attr(feature = "clap", clap(long, global = true, env = "RUSTIC_NO_CACHE"))]
#[cfg_attr(feature = "merge", merge(strategy = merge::bool::overwrite_false))]
no_cache: bool,
pub no_cache: bool,

/// Use this dir as cache dir instead of the standard cache dir
#[cfg_attr(
Expand All @@ -130,7 +130,7 @@ pub struct RepositoryOptions {
env = "RUSTIC_CACHE_DIR"
)
)]
cache_dir: Option<PathBuf>,
pub cache_dir: Option<PathBuf>,

/// Warm up needed data pack files by only requesting them without processing
#[cfg_attr(feature = "clap", clap(long, global = true))]
Expand All @@ -151,7 +151,7 @@ pub struct RepositoryOptions {

#[cfg_attr(feature = "clap", clap(skip))]
#[cfg_attr(feature = "merge", merge(strategy = overwrite))]
options: HashMap<String, String>,
pub options: HashMap<String, String>,
}

// TODO: Unused function
Expand Down

0 comments on commit 0503e67

Please sign in to comment.