Skip to content

Commit

Permalink
feat: Add interactive snapshots mode (#1114)
Browse files Browse the repository at this point in the history
Adds an interactive (TUI) mode. E.g. call `rustic snapshots -i`

Currently only a snapshot view is implemented with possibilities to
alter snapshots (label, tags, delete protection mark).

Use `--filter-*` to filter snapshots in the interactive mode
  • Loading branch information
aawsome authored Apr 13, 2024
1 parent 88b21a8 commit e8448f0
Show file tree
Hide file tree
Showing 15 changed files with 1,675 additions and 123 deletions.
118 changes: 118 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ rustic - fast, encrypted, deduplicated backups powered by Rust
"""

[features]
default = ["self-update", "webdav"]
default = ["self-update", "tui", "webdav"]
mimalloc = ["dep:mimalloc"]
jemallocator = ["dep:jemallocator-global"]
self-update = ["dep:self_update", "dep:semver"]
tui = ["dep:ratatui", "dep:crossterm", "dep:tui-textarea"]
webdav = ["dep:dav-server", "dep:warp", "dep:tokio", "rustic_core/webdav"]

[[bin]]
Expand Down Expand Up @@ -52,6 +53,11 @@ dav-server = { version = "0.5.8", default-features = false, features = ["warp-co
tokio = { version = "1", optional = true }
warp = { version = "0.3.6", optional = true }

# tui
crossterm = { version = "0.27", optional = true }
ratatui = { version = "0.26.1", optional = true }
tui-textarea = { version = "0.4.0", optional = true }

# logging
log = "0.4"

Expand Down
13 changes: 11 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub(crate) mod self_update;
pub(crate) mod show_config;
pub(crate) mod snapshots;
pub(crate) mod tag;
#[cfg(feature = "tui")]
pub(crate) mod tui;
#[cfg(feature = "webdav")]
pub(crate) mod webdav;

Expand All @@ -37,7 +39,7 @@ use crate::{
config::ConfigCmd, copy::CopyCmd, diff::DiffCmd, dump::DumpCmd, forget::ForgetCmd,
init::InitCmd, key::KeyCmd, list::ListCmd, ls::LsCmd, merge::MergeCmd, prune::PruneCmd,
repair::RepairCmd, repoinfo::RepoInfoCmd, restore::RestoreCmd, self_update::SelfUpdateCmd,
show_config::ShowConfigCmd, snapshots::SnapshotCmd, tag::TagCmd,
show_config::ShowConfigCmd, snapshots::SnapshotCmd, tag::TagCmd, tui::TuiCmd,
},
config::{progress_options::ProgressOptions, AllRepositoryOptions, RusticConfig},
{Application, RUSTIC_APP},
Expand Down Expand Up @@ -164,7 +166,14 @@ impl Runnable for EntryPoint {
// Set up panic hook for better error messages and logs
setup_panic!();

self.commands.run();
if self.config.global.interactive {
if matches!(self.commands, RusticCmd::Snapshots(_) | RusticCmd::Tag(_)) {
let tui = TuiCmd {};
tui.run();
}
} else {
self.commands.run();
}
RUSTIC_APP.shutdown(Shutdown::Graceful)
}
}
Expand Down
Loading

0 comments on commit e8448f0

Please sign in to comment.