-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #668 from openSUSE/cli_auto_questions
CLI automatic answers to questions
- Loading branch information
Showing
9 changed files
with
103 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use agama_lib::connection; | ||
use agama_lib::proxies::Questions1Proxy; | ||
use anyhow::{Context, Ok}; | ||
use clap::{Args, Subcommand, ValueEnum}; | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum QuestionsCommands { | ||
/// Set mode for answering questions. | ||
Mode(ModesArgs), | ||
} | ||
|
||
#[derive(Args, Debug)] | ||
pub struct ModesArgs { | ||
#[arg(value_enum)] | ||
value: Modes, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] | ||
pub enum Modes { | ||
Interactive, | ||
NonInteractive, | ||
} | ||
// TODO when more commands is added, refactor and add it to agama-lib and share a bit of functionality | ||
async fn set_mode(value: Modes) -> anyhow::Result<()> { | ||
match value { | ||
Modes::NonInteractive => { | ||
let connection = connection().await?; | ||
let proxy = Questions1Proxy::new(&connection) | ||
.await | ||
.context("Failed to connect to Questions service")?; | ||
|
||
// TODO: how to print dbus error in that anyhow? | ||
proxy | ||
.use_default_answer() | ||
.await | ||
.context("Failed to set default answer")?; | ||
} | ||
Modes::Interactive => log::info!("not implemented"), //TODO do it | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub async fn run(subcommand: QuestionsCommands) -> anyhow::Result<()> { | ||
match subcommand { | ||
QuestionsCommands::Mode(value) => set_mode(value.value).await, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
------------------------------------------------------------------- | ||
Tue Jul 18 13:32:04 UTC 2023 - Josef Reidinger <[email protected]> | ||
|
||
- Add to CLI "questions" subcommand with mode option to set | ||
interactive and non-interactive mode (gh#openSUSE/agama#668) | ||
|
||
------------------------------------------------------------------- | ||
Mon Jul 17 13:36:56 UTC 2023 - Imobach Gonzalez Sosa <[email protected]> | ||
|
||
|