Skip to content

Commit

Permalink
made name optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Weber committed Aug 6, 2023
1 parent f5ef284 commit 4b5003b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 4 additions & 5 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl<'x> SSS<'x> {
for z in blueprint.generate.iter().zip(shares) {
let share_data = Archive {
version: "9f1e0683-7655-4f73-940a-38fa580b5725".to_owned(),
name: if z.0.with_name { Some(z.0.name.clone()) } else { None },
comment: z.0.with_comment.clone(),
name: z.0.name.clone(),
comment: z.0.comment.clone(),
secret: if z.0.with_secret_info {
Some(SecretInfo {
num_shares: blueprint.generate.len(),
Expand Down Expand Up @@ -126,10 +126,9 @@ pub(crate) struct ShareGenBlueprint {
}
#[derive(Debug, serde::Deserialize)]
pub(crate) struct ShareGenInfo {
pub name: String,
pub path: String,
pub name: Option<String>,
pub password: Option<String>,
pub with_name: bool,
pub with_secret_info: bool,
pub with_comment: Option<String>,
pub comment: Option<String>,
}
20 changes: 11 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,25 @@ async fn main() -> Result<()> {
}

async fn ask_for_share_data() -> Result<ShareGenInfo> {
let name: String = dialoguer::Input::new().with_prompt("Name").interact()?;
let path: String = dialoguer::Input::new()
.with_prompt("Save to file")
.with_initial_text(&name)
.interact()?;
let path: String = dialoguer::Input::new().with_prompt("Save to file").interact()?;

let with_name = dialoguer::Confirm::new()
.with_prompt("Include name in share?")
.interact()?;
let name: Option<String> = if with_name {
Some(dialoguer::Input::new().with_prompt("Name").interact()?)
} else {
None
};

let with_secret_info = dialoguer::Confirm::new()
.with_prompt("Include secret info (num shares / threshold) in share?")
.interact()?;

let add_comment = dialoguer::Confirm::new()
let with_comment = dialoguer::Confirm::new()
.with_prompt("Add comment to share?")
.interact()?;
let with_comment: Option<String> = if add_comment {
let comment: Option<String> = if with_comment {
Some(dialoguer::Input::new().with_prompt("Comment").interact()?)
} else {
None
Expand All @@ -110,8 +113,7 @@ async fn ask_for_share_data() -> Result<ShareGenInfo> {
name,
path,
password,
with_name,
with_secret_info,
with_comment,
comment,
})
}

0 comments on commit 4b5003b

Please sign in to comment.