summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/backup.rs14
-rw-r--r--src/cmd/chunk.rs12
-rw-r--r--src/cmd/chunkify.rs4
-rw-r--r--src/cmd/gen_info.rs5
-rw-r--r--src/cmd/get_chunk.rs5
-rw-r--r--src/cmd/init.rs8
-rw-r--r--src/cmd/inspect.rs5
-rw-r--r--src/cmd/list.rs4
-rw-r--r--src/cmd/list_backup_versions.rs6
-rw-r--r--src/cmd/list_files.rs6
-rw-r--r--src/cmd/resolve.rs4
-rw-r--r--src/cmd/restore.rs14
-rw-r--r--src/cmd/show_config.rs4
-rw-r--r--src/cmd/show_gen.rs6
14 files changed, 45 insertions, 52 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs
index 80dbb1f..70e9eac 100644
--- a/src/cmd/backup.rs
+++ b/src/cmd/backup.rs
@@ -10,21 +10,21 @@ use crate::generation::GenId;
use crate::performance::{Clock, Performance};
use crate::schema::VersionComponent;
+use clap::Parser;
use log::info;
use std::time::SystemTime;
-use structopt::StructOpt;
use tempfile::tempdir;
use tokio::runtime::Runtime;
/// Make a backup.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct Backup {
/// Force a full backup, instead of an incremental one.
- #[structopt(long)]
+ #[clap(long)]
full: bool,
/// Backup schema major version to use.
- #[structopt(long)]
+ #[clap(long)]
backup_version: Option<VersionComponent>,
}
@@ -45,7 +45,7 @@ impl Backup {
let major = self.backup_version.unwrap_or(DEFAULT_SCHEMA_MAJOR);
let schema = schema_version(major)?;
- let client = BackupClient::new(config)?;
+ let mut client = BackupClient::new(config)?;
let trust = client
.get_client_trust()
.await?
@@ -68,7 +68,7 @@ impl Backup {
let (is_incremental, outcome) = if let Some(old_id) = old_id {
info!("incremental backup based on {}", old_id);
- let mut run = BackupRun::incremental(config, &client)?;
+ let mut run = BackupRun::incremental(config, &mut client)?;
let old = run.start(Some(&old_id), &oldtemp, perf).await?;
(
true,
@@ -77,7 +77,7 @@ impl Backup {
)
} else {
info!("fresh backup without a previous generation");
- let mut run = BackupRun::initial(config, &client)?;
+ let mut run = BackupRun::initial(config, &mut client)?;
let old = run.start(None, &oldtemp, perf).await?;
(
false,
diff --git a/src/cmd/chunk.rs b/src/cmd/chunk.rs
index 445d23f..293de20 100644
--- a/src/cmd/chunk.rs
+++ b/src/cmd/chunk.rs
@@ -5,22 +5,19 @@ use crate::chunkmeta::ChunkMeta;
use crate::cipher::CipherEngine;
use crate::config::ClientConfig;
use crate::error::ObnamError;
+use clap::Parser;
use std::path::PathBuf;
-use structopt::StructOpt;
/// Encrypt a chunk.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct EncryptChunk {
/// The name of the file containing the cleartext chunk.
- #[structopt(parse(from_os_str))]
filename: PathBuf,
/// Name of file where to write the encrypted chunk.
- #[structopt(parse(from_os_str))]
output: PathBuf,
/// Chunk metadata as JSON.
- #[structopt()]
json: String,
}
@@ -43,18 +40,15 @@ impl EncryptChunk {
}
/// Decrypt a chunk.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct DecryptChunk {
/// Name of file containing encrypted chunk.
- #[structopt(parse(from_os_str))]
filename: PathBuf,
/// Name of file where to write the cleartext chunk.
- #[structopt(parse(from_os_str))]
output: PathBuf,
/// Chunk metadata as JSON.
- #[structopt()]
json: String,
}
diff --git a/src/cmd/chunkify.rs b/src/cmd/chunkify.rs
index e2ce05f..91cb0be 100644
--- a/src/cmd/chunkify.rs
+++ b/src/cmd/chunkify.rs
@@ -4,10 +4,10 @@ use crate::config::ClientConfig;
use crate::engine::Engine;
use crate::error::ObnamError;
use crate::workqueue::WorkQueue;
+use clap::Parser;
use serde::Serialize;
use sha2::{Digest, Sha256};
use std::path::PathBuf;
-use structopt::StructOpt;
use tokio::fs::File;
use tokio::io::{AsyncReadExt, BufReader};
use tokio::runtime::Runtime;
@@ -18,7 +18,7 @@ use tokio::sync::mpsc;
const Q: usize = 8;
/// Split files into chunks and show their metadata.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct Chunkify {
/// Names of files to split into chunks.
filenames: Vec<PathBuf>,
diff --git a/src/cmd/gen_info.rs b/src/cmd/gen_info.rs
index 0aec103..901a0ae 100644
--- a/src/cmd/gen_info.rs
+++ b/src/cmd/gen_info.rs
@@ -4,16 +4,15 @@ use crate::chunk::ClientTrust;
use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
+use clap::Parser;
use log::info;
-use structopt::StructOpt;
use tempfile::NamedTempFile;
use tokio::runtime::Runtime;
/// Show metadata for a generation.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct GenInfo {
/// Reference of the generation.
- #[structopt()]
gen_ref: String,
}
diff --git a/src/cmd/get_chunk.rs b/src/cmd/get_chunk.rs
index 0b27084..1561492 100644
--- a/src/cmd/get_chunk.rs
+++ b/src/cmd/get_chunk.rs
@@ -4,15 +4,14 @@ use crate::chunkid::ChunkId;
use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
+use clap::Parser;
use std::io::{stdout, Write};
-use structopt::StructOpt;
use tokio::runtime::Runtime;
/// Fetch a chunk from the server.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct GetChunk {
/// Identifier of chunk to fetch.
- #[structopt()]
chunk_id: String,
}
diff --git a/src/cmd/init.rs b/src/cmd/init.rs
index 8e555ca..5950fbb 100644
--- a/src/cmd/init.rs
+++ b/src/cmd/init.rs
@@ -3,15 +3,15 @@
use crate::config::ClientConfig;
use crate::error::ObnamError;
use crate::passwords::{passwords_filename, Passwords};
-use structopt::StructOpt;
+use clap::Parser;
const PROMPT: &str = "Obnam passphrase: ";
/// Initialize client by setting passwords.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct Init {
/// Only for testing.
- #[structopt(long)]
+ #[clap(long)]
insecure_passphrase: Option<String>,
}
@@ -20,7 +20,7 @@ impl Init {
pub fn run(&self, config: &ClientConfig) -> Result<(), ObnamError> {
let passphrase = match &self.insecure_passphrase {
Some(x) => x.to_string(),
- None => rpassword::read_password_from_tty(Some(PROMPT)).unwrap(),
+ None => rpassword::prompt_password(PROMPT).unwrap(),
};
let passwords = Passwords::new(&passphrase);
diff --git a/src/cmd/inspect.rs b/src/cmd/inspect.rs
index 02801ae..3b41075 100644
--- a/src/cmd/inspect.rs
+++ b/src/cmd/inspect.rs
@@ -6,16 +6,15 @@ use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
+use clap::Parser;
use log::info;
-use structopt::StructOpt;
use tempfile::NamedTempFile;
use tokio::runtime::Runtime;
/// Make a backup.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct Inspect {
/// Reference to generation to inspect.
- #[structopt()]
gen_id: String,
}
diff --git a/src/cmd/list.rs b/src/cmd/list.rs
index bbb9c91..8bc6978 100644
--- a/src/cmd/list.rs
+++ b/src/cmd/list.rs
@@ -4,11 +4,11 @@ use crate::chunk::ClientTrust;
use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
-use structopt::StructOpt;
+use clap::Parser;
use tokio::runtime::Runtime;
/// List generations on the server.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct List {}
impl List {
diff --git a/src/cmd/list_backup_versions.rs b/src/cmd/list_backup_versions.rs
index 859d91c..c78ccfc 100644
--- a/src/cmd/list_backup_versions.rs
+++ b/src/cmd/list_backup_versions.rs
@@ -4,13 +4,13 @@ use crate::config::ClientConfig;
use crate::dbgen::{schema_version, DEFAULT_SCHEMA_MAJOR, SCHEMA_MAJORS};
use crate::error::ObnamError;
-use structopt::StructOpt;
+use clap::Parser;
/// List supported backup schema versions.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct ListSchemaVersions {
/// List only the default version.
- #[structopt(long)]
+ #[clap(long)]
default_only: bool,
}
diff --git a/src/cmd/list_files.rs b/src/cmd/list_files.rs
index fb4764d..e8276cd 100644
--- a/src/cmd/list_files.rs
+++ b/src/cmd/list_files.rs
@@ -6,15 +6,15 @@ use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
use crate::fsentry::{FilesystemEntry, FilesystemKind};
-use structopt::StructOpt;
+use clap::Parser;
use tempfile::NamedTempFile;
use tokio::runtime::Runtime;
/// List files in a backup.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct ListFiles {
/// Reference to backup to list files in.
- #[structopt(default_value = "latest")]
+ #[clap(default_value = "latest")]
gen_id: String,
}
diff --git a/src/cmd/resolve.rs b/src/cmd/resolve.rs
index 12432cc..a7774d7 100644
--- a/src/cmd/resolve.rs
+++ b/src/cmd/resolve.rs
@@ -4,11 +4,11 @@ use crate::chunk::ClientTrust;
use crate::client::BackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
-use structopt::StructOpt;
+use clap::Parser;
use tokio::runtime::Runtime;
/// Resolve a generation reference into a generation id.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct Resolve {
/// The generation reference.
generation: String,
diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs
index 223d481..58caf61 100644
--- a/src/cmd/restore.rs
+++ b/src/cmd/restore.rs
@@ -9,6 +9,7 @@ use crate::dbgen::FileId;
use crate::error::ObnamError;
use crate::fsentry::{FilesystemEntry, FilesystemKind};
use crate::generation::{LocalGeneration, LocalGenerationError};
+use clap::Parser;
use indicatif::{ProgressBar, ProgressStyle};
use libc::{chmod, mkfifo, timespec, utimensat, AT_FDCWD, AT_SYMLINK_NOFOLLOW};
use log::{debug, error, info};
@@ -20,19 +21,16 @@ use std::os::unix::fs::symlink;
use std::os::unix::net::UnixListener;
use std::path::StripPrefixError;
use std::path::{Path, PathBuf};
-use structopt::StructOpt;
use tempfile::NamedTempFile;
use tokio::runtime::Runtime;
/// Restore a backup.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct Restore {
/// Reference to generation to restore.
- #[structopt()]
gen_id: String,
/// Path to directory where restored files are written.
- #[structopt(parse(from_os_str))]
to: PathBuf,
}
@@ -301,13 +299,17 @@ fn create_progress_bar(file_count: FileId, verbose: bool) -> ProgressBar {
} else {
ProgressBar::hidden()
};
- let parts = vec![
+ let parts = [
"{wide_bar}",
"elapsed: {elapsed}",
"files: {pos}/{len}",
"current: {wide_msg}",
"{spinner}",
];
- progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n")));
+ progress.set_style(
+ ProgressStyle::default_bar()
+ .template(&parts.join("\n"))
+ .expect("create indicatif ProgressStyle value"),
+ );
progress
}
diff --git a/src/cmd/show_config.rs b/src/cmd/show_config.rs
index 7ac52ec..8e0ce30 100644
--- a/src/cmd/show_config.rs
+++ b/src/cmd/show_config.rs
@@ -2,10 +2,10 @@
use crate::config::ClientConfig;
use crate::error::ObnamError;
-use structopt::StructOpt;
+use clap::Parser;
/// Show actual client configuration.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct ShowConfig {}
impl ShowConfig {
diff --git a/src/cmd/show_gen.rs b/src/cmd/show_gen.rs
index f47a07b..95d3fd3 100644
--- a/src/cmd/show_gen.rs
+++ b/src/cmd/show_gen.rs
@@ -7,17 +7,17 @@ use crate::db::DbInt;
use crate::error::ObnamError;
use crate::fsentry::FilesystemKind;
use crate::generation::GenId;
+use clap::Parser;
use indicatif::HumanBytes;
use serde::Serialize;
-use structopt::StructOpt;
use tempfile::NamedTempFile;
use tokio::runtime::Runtime;
/// Show information about a generation.
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
pub struct ShowGeneration {
/// Reference to the generation. Defaults to latest.
- #[structopt(default_value = "latest")]
+ #[clap(default_value = "latest")]
gen_id: String,
}