-
Notifications
You must be signed in to change notification settings - Fork 432
feat: [cli] Pass optional args to get matches #2787
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"cli": minor | ||
--- | ||
|
||
Added `tauri_plugin_cli::matches_from`. This can be combined with the `args` passed to the callback of `tauri_plugin_single_instance` to parse the command line arguments passed to subsequent instances of the application. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,11 @@ impl Matches { | |
/// Ok(()) | ||
/// }); | ||
/// ``` | ||
pub fn get_matches(cli: &Config, package_info: &PackageInfo) -> crate::Result<Matches> { | ||
pub fn get_matches( | ||
cli: &Config, | ||
package_info: &PackageInfo, | ||
args: Option<Vec<String>>, | ||
) -> crate::Result<Matches> { | ||
Comment on lines
+82
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Legend-Master Curious and slightly bored here, hope you don't mind me asking. You called out the changes to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies, did not notice that the docs do mention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
let about = cli | ||
.description() | ||
.unwrap_or(&package_info.description.to_string()) | ||
|
@@ -92,7 +96,14 @@ pub fn get_matches(cli: &Config, package_info: &PackageInfo) -> crate::Result<Ma | |
Some(&about), | ||
cli, | ||
); | ||
match app.try_get_matches() { | ||
|
||
let matches = if let Some(args) = args { | ||
app.try_get_matches_from(args) | ||
} else { | ||
app.try_get_matches() | ||
}; | ||
|
||
match matches { | ||
Ok(matches) => Ok(get_matches_internal(cli, &matches)), | ||
Err(e) => match e.kind() { | ||
ErrorKind::DisplayHelp => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.