aboutsummaryrefslogtreecommitdiff
path: root/crates/dinggerd/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/dinggerd/src/main.rs')
-rw-r--r--crates/dinggerd/src/main.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/dinggerd/src/main.rs b/crates/dinggerd/src/main.rs
index 3707d51..2129bd2 100644
--- a/crates/dinggerd/src/main.rs
+++ b/crates/dinggerd/src/main.rs
@@ -5,6 +5,8 @@ mod integrations;
mod manifest_update;
mod names;
mod notify;
+mod restore;
+mod snapshot;
mod tmux;
mod watcher;
@@ -52,6 +54,24 @@ enum Command {
},
/// Wake the watcher so focus changes show up immediately (tmux hooks).
Poke,
+ /// Restore tmux sessions saved before tmux last stopped (a crash,
+ /// shutdown, or kill-server): windows, panes, layouts, directories.
+ /// Only adds what is missing; a bare session of the same name (what a
+ /// terminal creates on startup) is replaced, its clients moved over.
+ Restore {
+ /// Show what would happen without changing anything.
+ #[arg(long)]
+ dry_run: bool,
+ /// List the restore candidate and saved snapshots.
+ #[arg(long)]
+ list: bool,
+ /// Restore from this snapshot file instead of the candidate.
+ #[arg(long)]
+ from: Option<String>,
+ /// Restore only these sessions.
+ #[arg(long = "session")]
+ sessions: Vec<String>,
+ },
/// Install agent integrations (hook extensions that report state).
Install {
/// Agent to install the integration for.
@@ -112,6 +132,13 @@ fn main() {
// Best effort: a stopped watcher just means nothing to wake.
let _ = hooks::poke();
}
+ Command::Restore { dry_run, list, from, sessions } => {
+ let result = if list { restore::list() } else { restore::run(from.as_deref(), &sessions, dry_run) };
+ if let Err(err) = result {
+ eprintln!("dingger: {err}");
+ std::process::exit(1);
+ }
+ }
Command::Install { agent } => {
if let Err(err) = integrations::install(&agent) {
eprintln!("dingger: {err}");