feat(common): add SaveDocument API and CLI command
This commit is contained in:
parent
7bd0313b30
commit
1a7c125316
|
|
@ -35,6 +35,7 @@ Deferred manual/runtime verification (implemented after 2026-02-20 while user un
|
||||||
|
|
||||||
- `GetKiCadBinaryPath`
|
- `GetKiCadBinaryPath`
|
||||||
- `GetPluginSettingsPath`
|
- `GetPluginSettingsPath`
|
||||||
|
- `SaveDocument`
|
||||||
|
|
||||||
## KiCad v10 RC1.1 API Completion Matrix
|
## KiCad v10 RC1.1 API Completion Matrix
|
||||||
|
|
||||||
|
|
@ -55,11 +56,11 @@ Legend:
|
||||||
| Section | Proto Commands | Implemented | Coverage |
|
| Section | Proto Commands | Implemented | Coverage |
|
||||||
| --- | ---: | ---: | ---: |
|
| --- | ---: | ---: | ---: |
|
||||||
| Common (base) | 6 | 6 | 100% |
|
| Common (base) | 6 | 6 | 100% |
|
||||||
| Common editor/document | 23 | 15 | 65% |
|
| Common editor/document | 23 | 16 | 70% |
|
||||||
| Project manager | 5 | 3 | 60% |
|
| Project manager | 5 | 3 | 60% |
|
||||||
| Board editor (PCB) | 22 | 20 | 91% |
|
| Board editor (PCB) | 22 | 20 | 91% |
|
||||||
| Schematic editor (dedicated proto commands) | 0 | 0 | n/a |
|
| Schematic editor (dedicated proto commands) | 0 | 0 | n/a |
|
||||||
| **Total** | **56** | **44** | **79%** |
|
| **Total** | **56** | **45** | **80%** |
|
||||||
|
|
||||||
### Common (base)
|
### Common (base)
|
||||||
|
|
||||||
|
|
@ -78,7 +79,7 @@ Legend:
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `RefreshEditor` | Implemented | `KiCadClient::refresh_editor` |
|
| `RefreshEditor` | Implemented | `KiCadClient::refresh_editor` |
|
||||||
| `GetOpenDocuments` | Implemented | `KiCadClient::get_open_documents`, `KiCadClient::get_current_project_path`, `KiCadClient::has_open_board` |
|
| `GetOpenDocuments` | Implemented | `KiCadClient::get_open_documents`, `KiCadClient::get_current_project_path`, `KiCadClient::has_open_board` |
|
||||||
| `SaveDocument` | Not yet | - |
|
| `SaveDocument` | Implemented | `KiCadClient::save_document_raw`, `KiCadClient::save_document` |
|
||||||
| `SaveCopyOfDocument` | Not yet | - |
|
| `SaveCopyOfDocument` | Not yet | - |
|
||||||
| `RevertDocument` | Not yet | - |
|
| `RevertDocument` | Not yet | - |
|
||||||
| `RunAction` | Not yet | - |
|
| `RunAction` | Not yet | - |
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,12 @@ End a staged commit:
|
||||||
cargo run --bin kicad-ipc-cli -- --client-name write-test end-commit --id <commit-id> --action drop --message "cli test cleanup"
|
cargo run --bin kicad-ipc-cli -- --client-name write-test end-commit --id <commit-id> --action drop --message "cli test cleanup"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Save current board document:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --bin kicad-ipc-cli -- save-doc
|
||||||
|
```
|
||||||
|
|
||||||
Show summary of current PCB selection by item type:
|
Show summary of current PCB selection by item type:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ const CMD_GET_ITEMS_BY_ID: &str = "kiapi.common.commands.GetItemsById";
|
||||||
const CMD_GET_BOUNDING_BOX: &str = "kiapi.common.commands.GetBoundingBox";
|
const CMD_GET_BOUNDING_BOX: &str = "kiapi.common.commands.GetBoundingBox";
|
||||||
const CMD_HIT_TEST: &str = "kiapi.common.commands.HitTest";
|
const CMD_HIT_TEST: &str = "kiapi.common.commands.HitTest";
|
||||||
const CMD_GET_TITLE_BLOCK_INFO: &str = "kiapi.common.commands.GetTitleBlockInfo";
|
const CMD_GET_TITLE_BLOCK_INFO: &str = "kiapi.common.commands.GetTitleBlockInfo";
|
||||||
|
const CMD_SAVE_DOCUMENT: &str = "kiapi.common.commands.SaveDocument";
|
||||||
const CMD_SAVE_DOCUMENT_TO_STRING: &str = "kiapi.common.commands.SaveDocumentToString";
|
const CMD_SAVE_DOCUMENT_TO_STRING: &str = "kiapi.common.commands.SaveDocumentToString";
|
||||||
const CMD_SAVE_SELECTION_TO_STRING: &str = "kiapi.common.commands.SaveSelectionToString";
|
const CMD_SAVE_SELECTION_TO_STRING: &str = "kiapi.common.commands.SaveSelectionToString";
|
||||||
|
|
||||||
|
|
@ -1374,6 +1375,22 @@ impl KiCadClient {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn save_document_raw(&self) -> Result<prost_types::Any, KiCadError> {
|
||||||
|
let command = common_commands::SaveDocument {
|
||||||
|
document: Some(self.current_board_document_proto().await?),
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = self
|
||||||
|
.send_command(envelope::pack_any(&command, CMD_SAVE_DOCUMENT))
|
||||||
|
.await?;
|
||||||
|
response_payload_as_any(response, RES_PROTOBUF_EMPTY)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn save_document(&self) -> Result<(), KiCadError> {
|
||||||
|
let _ = self.save_document_raw().await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_board_as_string(&self) -> Result<String, KiCadError> {
|
pub async fn get_board_as_string(&self) -> Result<String, KiCadError> {
|
||||||
let command = common_commands::SaveDocumentToString {
|
let command = common_commands::SaveDocumentToString {
|
||||||
document: Some(self.current_board_document_proto().await?),
|
document: Some(self.current_board_document_proto().await?),
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue