Skip to content

Commit

Permalink
Merge pull request #263 from nobriot/nwoltmann/remove-the-infinite-ye…
Browse files Browse the repository at this point in the history
…s-loop

Allow users to say no when writing to fishnet.ini
  • Loading branch information
niklasf authored Mar 30, 2024
2 parents fbc86ea + 20f580a commit 8c5e24c
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,27 @@ pub async fn parse_and_configure(client: &Client) -> Opt {
.read_line(&mut write)
.expect("read confirmation from stdin");

if let Ok(Toggle::Yes | Toggle::Default) = Toggle::from_str(&write) {
let contents = ini.writes();
fs::write(opt.conf(), contents).expect("write config");
break;
match Toggle::from_str(&write) {
Ok(Toggle::Yes | Toggle::Default) => {
let contents = ini.writes();
fs::write(opt.conf(), contents).expect("write config");
break;
}
Ok(Toggle::No) => {
let contents = ini.writes();
eprint!(
"Writing to {:?} is necessary to continue. Exiting.\n",
opt.conf()
);
eprint!("Here is the fishnet.ini contents if you need them:\n");
eprint!("-----------------------------------------------------\n");
eprint!("{}", contents);
eprint!("-----------------------------------------------------\n");
std::process::exit(0);
}
Err(_) => {
continue;
}
}
}

Expand Down

0 comments on commit 8c5e24c

Please sign in to comment.