From 3258b8fb749beec100eddcdbcdae52ca2a9d1f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 25 Jun 2025 23:52:16 +0000 Subject: [PATCH] prompt user before rebuilding share --- src/bin/shrupl.rs | 4 ++-- src/output.rs | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/bin/shrupl.rs b/src/bin/shrupl.rs index 9ae6ede..31ac3e9 100644 --- a/src/bin/shrupl.rs +++ b/src/bin/shrupl.rs @@ -90,13 +90,13 @@ fn main() { match p { // Error 404 (File not found) error::Parameter::FileID(fid) => { - info!("requeueing file {fid:?}"); + info!("retrying file {fid:?}"); state.abort_upload(); } // Error 404 (Share not found) error::Parameter::ShareID(sid) => { - // TODO ask + output::prompt_rebuild_share(); info!("rebuilding share {sid:?}"); // rebuild share diff --git a/src/output.rs b/src/output.rs index 7e52946..aa17cd4 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,7 +1,7 @@ use std::{fmt, process, sync::LazyLock}; use console::{StyledObject, style}; -use dialoguer::{Select, theme::ColorfulTheme}; +use dialoguer::{Confirm, Select, theme::ColorfulTheme}; use indicatif::{ProgressBar, ProgressStyle}; use log::{error, info}; @@ -36,6 +36,23 @@ pub fn prompt_continue() -> bool { selection == 0 } +pub fn prompt_rebuild_share() { + let prompt = format!( + "Target Share cannot be accessed. {}", + style("Completely restart upload?").cyan() + ); + + let selection = Confirm::with_theme(&ColorfulTheme::default()) + .with_prompt(prompt) + .default(true) + .interact() + .unwrap_or(false); + + if selection == false { + process::exit(0); + } +} + pub fn style_all<'t, F>(strs: &[&'t str], f: F) -> Vec where F: Fn(StyledObject<&'t str>) -> StyledObject<&'t str>,