massa_models/config/
massa_disclaimer.rs1use super::COMMUNITY_CHARTER_CONTENT;
2use std::path::PathBuf;
3
4pub fn handle_disclaimer(
6 auto_accept_community_charter: bool,
7 approved_community_charter_file_path: &PathBuf,
8) {
9 if !auto_accept_community_charter && !approved_community_charter_file_path.exists() {
10 let mut prompt = COMMUNITY_CHARTER_CONTENT.to_string();
11 prompt.push_str("\n\nDo you accept the Community Charter?");
12
13 let accepted_community_charter = dialoguer::Confirm::new()
14 .with_prompt(prompt.clone())
15 .default(false)
16 .report(false)
17 .interact()
18 .unwrap_or_else(|_| {
19 prompt.push_str("\n\nError: Not in a terminal, could not get user input.\n\n");
20 print!("{}", prompt);
21 false
22 });
23
24 if !accepted_community_charter {
25 panic!("You have to approve the Community Charter to continue. You can read it in 'COMMUNITY_CHARTER.md' and re-run with the flag '-a' or '--accept-community-charter' to automatically accept them. Exiting.");
26 }
27 }
28 if !approved_community_charter_file_path.exists() {
30 std::fs::File::create(approved_community_charter_file_path)
31 .expect("Failed to create the approved disclaimer file");
32 }
33}