Files
nyaterm/scripts/import-quick-commands.ps1
T
Kang 312d53a6f5 feat: Implement quick commands import functionality with scripts and example JSON
This commit introduces two new scripts, `import-quick-commands.ps1` and `import-quick-commands.sh`, for importing quick commands into the NyaTerm database. It also adds an example JSON file, `quick-commands.import.example.json`, demonstrating the expected format for quick commands and categories. Additionally, a new Rust example, `import_quick_commands.rs`, is added to handle the import logic, including options for database path, replacement, dry run, and backup. This enhancement streamlines the process of managing quick commands within the application.
2026-05-12 13:17:19 +08:00

41 lines
685 B
PowerShell

param(
[Parameter(Mandatory = $true, Position = 0)]
[string]$InputJson,
[string]$DatabasePath,
[switch]$Replace,
[switch]$DryRun,
[switch]$NoBackup
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$manifestPath = Join-Path $repoRoot "src-tauri\Cargo.toml"
$cargoArgs = @(
"run",
"--manifest-path",
$manifestPath,
"--example",
"import_quick_commands",
"--",
$InputJson
)
if ($DatabasePath) {
$cargoArgs += @("--db", $DatabasePath)
}
if ($Replace) {
$cargoArgs += "--replace"
}
if ($DryRun) {
$cargoArgs += "--dry-run"
}
if ($NoBackup) {
$cargoArgs += "--no-backup"
}
& cargo @cargoArgs
exit $LASTEXITCODE