Compare commits

..

3 Commits

Author SHA1 Message Date
64a874252a 1.1.1 2022-05-30 00:28:51 +02:00
c6b3934ca5 Update dependencies 2022-05-30 00:27:57 +02:00
3af70f3647 Add verbose flag 2022-05-30 00:27:35 +02:00
3 changed files with 31 additions and 13 deletions

22
Cargo.lock generated
View File

@ -42,7 +42,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "butterup" name = "butterup"
version = "1.1.0" version = "1.1.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -161,9 +161,9 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.8.1" version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
@ -206,9 +206,9 @@ dependencies = [
[[package]] [[package]]
name = "libz-sys" name = "libz-sys"
version = "1.1.6" version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e7e15d7610cce1d9752e137625f14e61a28cd45929b6e12e47b50fe154ee2e" checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@ -285,9 +285,9 @@ dependencies = [
[[package]] [[package]]
name = "os_str_bytes" name = "os_str_bytes"
version = "6.0.1" version = "6.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d8d0b2f198229de29dca79676f2738ff952edf3fde542eb8bf94d8c21b435" checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
@ -389,9 +389,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.5.5" version = "1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -400,9 +400,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.25" version = "0.6.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "butterup" name = "butterup"
description = "Backup btrfs snapshots over SSH" description = "Backup btrfs snapshots over SSH"
version = "1.1.0" version = "1.1.1"
authors = ["Joakim Hulthe <joakim@hulthe.net>"] authors = ["Joakim Hulthe <joakim@hulthe.net>"]
license = "MPL-2.0" license = "MPL-2.0"
edition = "2018" edition = "2018"

View File

@ -10,6 +10,7 @@ mod util;
use actions::{list, show_plan, sync}; use actions::{list, show_plan, sync};
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
use clap::{crate_version, Parser}; use clap::{crate_version, Parser};
use log::LevelFilter;
use remote::Remote; use remote::Remote;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::path::PathBuf; use std::path::PathBuf;
@ -21,6 +22,14 @@ pub type FileList = BTreeMap<TimeStamp, String>;
#[derive(Parser)] #[derive(Parser)]
#[clap(version = crate_version!())] #[clap(version = crate_version!())]
pub struct Opt { pub struct Opt {
/// Log more stuff
#[clap(long, short, parse(from_occurrences))]
verbose: u8,
/// Do not output anything but errors.
#[clap(long, short)]
quiet: bool,
/// The path of the backup directory on the local filesystem /// The path of the backup directory on the local filesystem
#[clap(short = 'l', long)] #[clap(short = 'l', long)]
path: PathBuf, path: PathBuf,
@ -64,7 +73,16 @@ pub enum Action {
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
let opt = Opt::parse(); let opt = Opt::parse();
pretty_env_logger::init(); let log_level = match opt.verbose {
0 if opt.quiet => LevelFilter::Error,
0 => LevelFilter::Info,
1 => LevelFilter::Debug,
2.. => LevelFilter::Trace,
};
pretty_env_logger::formatted_builder()
.filter(None, log_level)
.init();
match opt.action { match opt.action {
Action::Backup { all } => sync::run(&opt, all)?, Action::Backup { all } => sync::run(&opt, all)?,