feat(base): add GetKiCadBinaryPath API and CLI command
This commit is contained in:
parent
3305de0a8e
commit
e7390f6549
10
README.md
10
README.md
|
|
@ -31,6 +31,10 @@ Commands wrapped in this crate but currently unhandled/unsupported by this KiCad
|
|||
| --- | --- | --- |
|
||||
| `RefreshEditor` | `AS_UNHANDLED` | KiCad responds `no handler available for request of type kiapi.common.commands.RefreshEditor`. |
|
||||
|
||||
Deferred manual/runtime verification (implemented after 2026-02-20 while user unavailable):
|
||||
|
||||
- `GetKiCadBinaryPath`
|
||||
|
||||
## KiCad v10 RC1.1 API Completion Matrix
|
||||
|
||||
Source of truth for this matrix:
|
||||
|
|
@ -49,12 +53,12 @@ Legend:
|
|||
|
||||
| Section | Proto Commands | Implemented | Coverage |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Common (base) | 6 | 4 | 67% |
|
||||
| Common (base) | 6 | 5 | 83% |
|
||||
| Common editor/document | 23 | 15 | 65% |
|
||||
| Project manager | 5 | 3 | 60% |
|
||||
| Board editor (PCB) | 22 | 20 | 91% |
|
||||
| Schematic editor (dedicated proto commands) | 0 | 0 | n/a |
|
||||
| **Total** | **56** | **42** | **75%** |
|
||||
| **Total** | **56** | **43** | **77%** |
|
||||
|
||||
### Common (base)
|
||||
|
||||
|
|
@ -62,7 +66,7 @@ Legend:
|
|||
| --- | --- | --- |
|
||||
| `Ping` | Implemented | `KiCadClient::ping` |
|
||||
| `GetVersion` | Implemented | `KiCadClient::get_version` |
|
||||
| `GetKiCadBinaryPath` | Not yet | - |
|
||||
| `GetKiCadBinaryPath` | Implemented | `KiCadClient::get_kicad_binary_path_raw`, `KiCadClient::get_kicad_binary_path` |
|
||||
| `GetTextExtents` | Implemented | `KiCadClient::get_text_extents_raw`, `KiCadClient::get_text_extents` |
|
||||
| `GetTextAsShapes` | Implemented | `KiCadClient::get_text_as_shapes_raw`, `KiCadClient::get_text_as_shapes` |
|
||||
| `GetPluginSettingsPath` | Not yet | - |
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ Version:
|
|||
cargo run --bin kicad-ipc-cli -- version
|
||||
```
|
||||
|
||||
Resolve KiCad binary path (default `kicad-cli`):
|
||||
|
||||
```bash
|
||||
cargo run --bin kicad-ipc-cli -- kicad-binary-path --binary-name kicad-cli
|
||||
```
|
||||
|
||||
List open PCB docs:
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ const KICAD_API_TOKEN_ENV: &str = "KICAD_API_TOKEN";
|
|||
|
||||
const CMD_PING: &str = "kiapi.common.commands.Ping";
|
||||
const CMD_GET_VERSION: &str = "kiapi.common.commands.GetVersion";
|
||||
const CMD_GET_KICAD_BINARY_PATH: &str = "kiapi.common.commands.GetKiCadBinaryPath";
|
||||
const CMD_GET_NET_CLASSES: &str = "kiapi.common.commands.GetNetClasses";
|
||||
const CMD_GET_TEXT_VARIABLES: &str = "kiapi.common.commands.GetTextVariables";
|
||||
const CMD_EXPAND_TEXT_VARIABLES: &str = "kiapi.common.commands.ExpandTextVariables";
|
||||
|
|
@ -82,6 +83,7 @@ const CMD_SAVE_DOCUMENT_TO_STRING: &str = "kiapi.common.commands.SaveDocumentToS
|
|||
const CMD_SAVE_SELECTION_TO_STRING: &str = "kiapi.common.commands.SaveSelectionToString";
|
||||
|
||||
const RES_GET_VERSION: &str = "kiapi.common.commands.GetVersionResponse";
|
||||
const RES_PATH_RESPONSE: &str = "kiapi.common.commands.PathResponse";
|
||||
const RES_NET_CLASSES_RESPONSE: &str = "kiapi.common.commands.NetClassesResponse";
|
||||
const RES_TEXT_VARIABLES: &str = "kiapi.common.project.TextVariables";
|
||||
const RES_EXPAND_TEXT_VARIABLES_RESPONSE: &str =
|
||||
|
|
@ -337,6 +339,28 @@ impl KiCadClient {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn get_kicad_binary_path_raw(
|
||||
&self,
|
||||
binary_name: impl Into<String>,
|
||||
) -> Result<prost_types::Any, KiCadError> {
|
||||
let command = common_commands::GetKiCadBinaryPath {
|
||||
binary_name: binary_name.into(),
|
||||
};
|
||||
let response = self
|
||||
.send_command(envelope::pack_any(&command, CMD_GET_KICAD_BINARY_PATH))
|
||||
.await?;
|
||||
response_payload_as_any(response, RES_PATH_RESPONSE)
|
||||
}
|
||||
|
||||
pub async fn get_kicad_binary_path(
|
||||
&self,
|
||||
binary_name: impl Into<String>,
|
||||
) -> Result<String, KiCadError> {
|
||||
let payload = self.get_kicad_binary_path_raw(binary_name).await?;
|
||||
let response: common_commands::PathResponse = decode_any(&payload, RES_PATH_RESPONSE)?;
|
||||
Ok(response.path)
|
||||
}
|
||||
|
||||
pub async fn get_open_documents(
|
||||
&self,
|
||||
document_type: DocumentType,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue