-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI automatic answers to questions #668
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6271551
update proxies with new question interface
jreidinger f1bc1b0
Add command to set default answers for questions
jreidinger 12ee889
formatting
jreidinger 55815d6
Add example to object path method
jreidinger 2e2c108
Change commands for questions
jreidinger d507928
remove unused use
jreidinger 7a9c614
update cli guidelines
jreidinger c0ec508
Apply suggestions from code review
jreidinger 1d74a2b
apply suggestion from jilopez for doc
jreidinger f36e29b
fix formatting
jreidinger b4315b1
changes
jreidinger ef7ca5e
Merge remote-tracking branch 'origin/master' into cli_auto_questions
jreidinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]> | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware that the code which is specific to the CLI should live in
agama-cli
. That's the main intention of this package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, I mean here code that handles questions, do connection, use Question API and so on. But lets see how future will look like. For rust it is nice that strict separation of public and private, so it is easy to refactor internal stuff.