This commit is contained in:
+21
-1
@@ -1,6 +1,7 @@
|
||||
use rabby_core::{
|
||||
demo_dashboard, wallet_feature_summary, WalletDashboard, WalletFeatureStatus, Workspace,
|
||||
};
|
||||
use rabby_runtime::local_terminal::{LocalCommand, LocalCommandOutput, LocalTerminal};
|
||||
use rabby_runtime::wallet_vault::{EncryptedWalletVault, WalletVaultStatus};
|
||||
use serde::Serialize;
|
||||
use std::path::PathBuf;
|
||||
@@ -58,6 +59,17 @@ fn load_wallet_vault(path: String, passphrase: String) -> Result<WalletDashboard
|
||||
EncryptedWalletVault::load_dashboard(path, &passphrase).map_err(|err| err.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn run_local_command(command: String, cwd: Option<String>) -> Result<LocalCommandOutput, String> {
|
||||
let mut local_command = LocalCommand::new(command);
|
||||
if let Some(cwd) = cwd {
|
||||
local_command = local_command.with_cwd(cwd);
|
||||
}
|
||||
LocalTerminal::default()
|
||||
.run(local_command)
|
||||
.map_err(|err| format!("{err:?}"))
|
||||
}
|
||||
|
||||
fn resolve_vault_path(path: Option<String>) -> PathBuf {
|
||||
path.map(PathBuf::from)
|
||||
.unwrap_or_else(|| std::env::temp_dir().join("rabby-demo-wallet-vault.json"))
|
||||
@@ -70,7 +82,8 @@ fn main() {
|
||||
wallet_mvp_summary,
|
||||
wallet_dashboard,
|
||||
save_demo_wallet_vault,
|
||||
load_wallet_vault
|
||||
load_wallet_vault,
|
||||
run_local_command
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("failed to run Rabby Tauri application");
|
||||
@@ -94,4 +107,11 @@ mod tests {
|
||||
let path = resolve_vault_path(Some("/tmp/custom-rabby-vault.json".to_string()));
|
||||
assert_eq!(path, PathBuf::from("/tmp/custom-rabby-vault.json"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_command_tauri_bridge_captures_output() {
|
||||
let output = run_local_command("printf tauri-local".to_string(), None).unwrap();
|
||||
assert_eq!(output.exit_code, 0);
|
||||
assert_eq!(output.stdout, "tauri-local");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user