From fa056ce6f103937b8ae09c11504dc5569def2f5b Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Thu, 14 Sep 2023 21:40:11 +0200 Subject: [PATCH 1/7] improve cli documentation for questions --- rust/agama-cli/src/commands.rs | 9 ++++++++- rust/agama-cli/src/questions.rs | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rust/agama-cli/src/commands.rs b/rust/agama-cli/src/commands.rs index 9c07516988..a7224e152b 100644 --- a/rust/agama-cli/src/commands.rs +++ b/rust/agama-cli/src/commands.rs @@ -21,7 +21,14 @@ pub enum Commands { /// Autoinstallation profile handling #[command(subcommand)] Profile(ProfileCommands), - /// Questions handling + /// Configuration for questions that come from installer + /// + /// Questions are raised when unexpected situation happen in Installer + /// like if encrypted partition is detected and cannot be inspected, + /// if repository is sign by unknown GPG key or if installer is not sure + /// if multipath should be activated. + /// + /// For more details see official agama documentation for Questions. #[command(subcommand)] Questions(QuestionsCommands), } diff --git a/rust/agama-cli/src/questions.rs b/rust/agama-cli/src/questions.rs index 8bce0cb928..28d8f1920b 100644 --- a/rust/agama-cli/src/questions.rs +++ b/rust/agama-cli/src/questions.rs @@ -5,9 +5,19 @@ use clap::{Args, Subcommand, ValueEnum}; #[derive(Subcommand, Debug)] pub enum QuestionsCommands { - /// Set mode for answering questions. + /// Sets the mode for answering questions. + /// + /// It allows to decide if questions will be interactive or + /// if it should not block installation. Mode(ModesArgs), + /// Loads predefined answers to questions. + /// + /// It allows to predefine answers for certain questions to skip + /// them in interactive mode or change answer in automatic mode. + /// + /// For more details and examples see official Agama documentation. Answers { + /// Local path to file with answers in YAML format path: String, }, } From 47452df9c354af229d0c8f5d44587bd7ad207b20 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Thu, 14 Sep 2023 21:45:53 +0200 Subject: [PATCH 2/7] changes --- rust/package/agama-cli.changes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/package/agama-cli.changes b/rust/package/agama-cli.changes index 9999eb7733..5f0d489ff8 100644 --- a/rust/package/agama-cli.changes +++ b/rust/package/agama-cli.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Sep 14 19:44:57 UTC 2023 - Josef Reidinger + +- Improve questions CLI help text (gh#openSUSE/agama#754) + ------------------------------------------------------------------- Wed Sep 13 09:27:22 UTC 2023 - Knut Anderssen From 450e58b3c25d7b1ab37c6ac06cf010ae5a06de05 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Fri, 15 Sep 2023 10:19:17 +0200 Subject: [PATCH 3/7] fmt rust --- rust/agama-cli/src/commands.rs | 4 ++-- rust/agama-cli/src/questions.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/agama-cli/src/commands.rs b/rust/agama-cli/src/commands.rs index a7224e152b..e751c79b51 100644 --- a/rust/agama-cli/src/commands.rs +++ b/rust/agama-cli/src/commands.rs @@ -22,12 +22,12 @@ pub enum Commands { #[command(subcommand)] Profile(ProfileCommands), /// Configuration for questions that come from installer - /// + /// /// Questions are raised when unexpected situation happen in Installer /// like if encrypted partition is detected and cannot be inspected, /// if repository is sign by unknown GPG key or if installer is not sure /// if multipath should be activated. - /// + /// /// For more details see official agama documentation for Questions. #[command(subcommand)] Questions(QuestionsCommands), diff --git a/rust/agama-cli/src/questions.rs b/rust/agama-cli/src/questions.rs index 28d8f1920b..5b9edee5a1 100644 --- a/rust/agama-cli/src/questions.rs +++ b/rust/agama-cli/src/questions.rs @@ -6,15 +6,15 @@ use clap::{Args, Subcommand, ValueEnum}; #[derive(Subcommand, Debug)] pub enum QuestionsCommands { /// Sets the mode for answering questions. - /// + /// /// It allows to decide if questions will be interactive or /// if it should not block installation. Mode(ModesArgs), /// Loads predefined answers to questions. - /// + /// /// It allows to predefine answers for certain questions to skip /// them in interactive mode or change answer in automatic mode. - /// + /// /// For more details and examples see official Agama documentation. Answers { /// Local path to file with answers in YAML format From c5a7cd8a44c976b0212dd1d22b793a832e2b9b33 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Fri, 15 Sep 2023 10:43:50 +0200 Subject: [PATCH 4/7] add wrap_help feature of clap for better help wrapping --- rust/Cargo.lock | 11 +++++++++++ rust/agama-cli/Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e9d73fbda1..f939274673 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -493,6 +493,7 @@ dependencies = [ "bitflags", "clap_lex", "strsim", + "terminal_size", ] [[package]] @@ -1804,6 +1805,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "thiserror" version = "1.0.43" diff --git a/rust/agama-cli/Cargo.toml b/rust/agama-cli/Cargo.toml index fcf9039578..d66c105d21 100644 --- a/rust/agama-cli/Cargo.toml +++ b/rust/agama-cli/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = { version = "4.1.4", features = ["derive"] } +clap = { version = "4.1.4", features = ["derive", "wrap_help"] } agama-lib = { path="../agama-lib" } agama-settings = { path="../agama-settings" } serde = { version = "1.0.152" } From b9a7e4cc4f7d131b4ca151a437e7f19a60830e79 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Fri, 15 Sep 2023 18:03:46 +0200 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Martin Vidner --- rust/agama-cli/src/commands.rs | 6 +++--- rust/agama-cli/src/questions.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/agama-cli/src/commands.rs b/rust/agama-cli/src/commands.rs index e751c79b51..c685eb0767 100644 --- a/rust/agama-cli/src/commands.rs +++ b/rust/agama-cli/src/commands.rs @@ -23,9 +23,9 @@ pub enum Commands { Profile(ProfileCommands), /// Configuration for questions that come from installer /// - /// Questions are raised when unexpected situation happen in Installer - /// like if encrypted partition is detected and cannot be inspected, - /// if repository is sign by unknown GPG key or if installer is not sure + /// Questions are raised when an unexpected situation happens in the installer: + /// like if an encrypted partition is detected and cannot be inspected, + /// if a repository is signed by an unknown GPG key, or if the installer is not sure /// if multipath should be activated. /// /// For more details see official agama documentation for Questions. diff --git a/rust/agama-cli/src/questions.rs b/rust/agama-cli/src/questions.rs index 5b9edee5a1..f27d4a3cd6 100644 --- a/rust/agama-cli/src/questions.rs +++ b/rust/agama-cli/src/questions.rs @@ -8,7 +8,7 @@ pub enum QuestionsCommands { /// Sets the mode for answering questions. /// /// It allows to decide if questions will be interactive or - /// if it should not block installation. + /// if they should not block installation. Mode(ModesArgs), /// Loads predefined answers to questions. /// From 651ef1793f13fc9b5c6f1f467d7c81985fd77aaf Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 18 Sep 2023 11:45:05 +0200 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Martin Vidner --- rust/agama-cli/src/commands.rs | 2 +- rust/agama-cli/src/questions.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/agama-cli/src/commands.rs b/rust/agama-cli/src/commands.rs index c685eb0767..45d83b78da 100644 --- a/rust/agama-cli/src/commands.rs +++ b/rust/agama-cli/src/commands.rs @@ -23,7 +23,7 @@ pub enum Commands { Profile(ProfileCommands), /// Configuration for questions that come from installer /// - /// Questions are raised when an unexpected situation happens in the installer: + /// Questions are raised when an unexpected (by the user) situation happens in the installer: /// like if an encrypted partition is detected and cannot be inspected, /// if a repository is signed by an unknown GPG key, or if the installer is not sure /// if multipath should be activated. diff --git a/rust/agama-cli/src/questions.rs b/rust/agama-cli/src/questions.rs index f27d4a3cd6..51d1380068 100644 --- a/rust/agama-cli/src/questions.rs +++ b/rust/agama-cli/src/questions.rs @@ -16,6 +16,7 @@ pub enum QuestionsCommands { /// them in interactive mode or change answer in automatic mode. /// /// For more details and examples see official Agama documentation. + /// https://github.com/openSUSE/agama/blob/master/doc/questions.md Answers { /// Local path to file with answers in YAML format path: String, From 487e3a77d6de4a9ee95de838f0c8f63645cf53aa Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 18 Sep 2023 13:01:57 +0200 Subject: [PATCH 7/7] make rust linter happy --- rust/agama-cli/src/questions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/agama-cli/src/questions.rs b/rust/agama-cli/src/questions.rs index 51d1380068..c73dc9d055 100644 --- a/rust/agama-cli/src/questions.rs +++ b/rust/agama-cli/src/questions.rs @@ -16,7 +16,7 @@ pub enum QuestionsCommands { /// them in interactive mode or change answer in automatic mode. /// /// For more details and examples see official Agama documentation. - /// https://github.com/openSUSE/agama/blob/master/doc/questions.md + /// https://github.com/openSUSE/agama/blob/master/doc/questions.md Answers { /// Local path to file with answers in YAML format path: String,