MCPcopy Create free account
hub / github.com/Recordscript/recordscript / alert

Function alert

libs/hbb_common/src/platform/macos.rs:28–55  ·  view source on GitHub ↗

Firstly run the specified app, then alert a dialog. Return the clicked button value. # Arguments `app` - The app to execute the script. `alert_type` - Alert type. . informational, warning, critical `title` - The alert title. `message` - The alert message. `buttons` - The buttons to show.

(
    app: String,
    alert_type: String,
    title: String,
    message: String,
    buttons: Vec<String>,
)

Source from the content-addressed store, hash-verified

26/// * `message` - The alert message.
27/// * `buttons` - The buttons to show.
28pub fn alert(
29 app: String,
30 alert_type: String,
31 title: String,
32 message: String,
33 buttons: Vec<String>,
34) -> ResultType<String> {
35 let script = osascript::JavaScript::new(&format!(
36 "
37 var App = Application('{}');
38 App.includeStandardAdditions = true;
39 return App.displayAlert($params.title, {{
40 message: $params.message,
41 'as': $params.alert_type,
42 buttons: $params.buttons,
43 }});
44 ",
45 app
46 ));
47
48 let result: AlertResult = script.execute_with_params(AlertParams {
49 title,
50 message,
51 alert_type,
52 buttons,
53 })?;
54 Ok(result.button)
55}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected