feat(common): add SaveCopyOfDocument API and CLI command
This commit is contained in:
parent
1a7c125316
commit
14856ec9d6
|
|
@ -36,6 +36,7 @@ Deferred manual/runtime verification (implemented after 2026-02-20 while user un
|
||||||
- `GetKiCadBinaryPath`
|
- `GetKiCadBinaryPath`
|
||||||
- `GetPluginSettingsPath`
|
- `GetPluginSettingsPath`
|
||||||
- `SaveDocument`
|
- `SaveDocument`
|
||||||
|
- `SaveCopyOfDocument`
|
||||||
|
|
||||||
## KiCad v10 RC1.1 API Completion Matrix
|
## KiCad v10 RC1.1 API Completion Matrix
|
||||||
|
|
||||||
|
|
@ -56,11 +57,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 | 16 | 70% |
|
| Common editor/document | 23 | 17 | 74% |
|
||||||
| 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** | **45** | **80%** |
|
| **Total** | **56** | **46** | **82%** |
|
||||||
|
|
||||||
### Common (base)
|
### Common (base)
|
||||||
|
|
||||||
|
|
@ -80,7 +81,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` | Implemented | `KiCadClient::save_document_raw`, `KiCadClient::save_document` |
|
| `SaveDocument` | Implemented | `KiCadClient::save_document_raw`, `KiCadClient::save_document` |
|
||||||
| `SaveCopyOfDocument` | Not yet | - |
|
| `SaveCopyOfDocument` | Implemented | `KiCadClient::save_copy_of_document_raw`, `KiCadClient::save_copy_of_document` |
|
||||||
| `RevertDocument` | Not yet | - |
|
| `RevertDocument` | Not yet | - |
|
||||||
| `RunAction` | Not yet | - |
|
| `RunAction` | Not yet | - |
|
||||||
| `BeginCommit` | Implemented | `KiCadClient::begin_commit_raw`, `KiCadClient::begin_commit` |
|
| `BeginCommit` | Implemented | `KiCadClient::begin_commit_raw`, `KiCadClient::begin_commit` |
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,12 @@ Save current board document:
|
||||||
cargo run --bin kicad-ipc-cli -- save-doc
|
cargo run --bin kicad-ipc-cli -- save-doc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Save a copy of current board document:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --bin kicad-ipc-cli -- save-copy --path /tmp/example.kicad_pcb --overwrite --include-project
|
||||||
|
```
|
||||||
|
|
||||||
Show summary of current PCB selection by item type:
|
Show summary of current PCB selection by item type:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ 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: &str = "kiapi.common.commands.SaveDocument";
|
||||||
|
const CMD_SAVE_COPY_OF_DOCUMENT: &str = "kiapi.common.commands.SaveCopyOfDocument";
|
||||||
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";
|
||||||
|
|
||||||
|
|
@ -1391,6 +1392,39 @@ impl KiCadClient {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn save_copy_of_document_raw(
|
||||||
|
&self,
|
||||||
|
path: impl Into<String>,
|
||||||
|
overwrite: bool,
|
||||||
|
include_project: bool,
|
||||||
|
) -> Result<prost_types::Any, KiCadError> {
|
||||||
|
let command = common_commands::SaveCopyOfDocument {
|
||||||
|
document: Some(self.current_board_document_proto().await?),
|
||||||
|
path: path.into(),
|
||||||
|
options: Some(common_commands::SaveOptions {
|
||||||
|
overwrite,
|
||||||
|
include_project,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = self
|
||||||
|
.send_command(envelope::pack_any(&command, CMD_SAVE_COPY_OF_DOCUMENT))
|
||||||
|
.await?;
|
||||||
|
response_payload_as_any(response, RES_PROTOBUF_EMPTY)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn save_copy_of_document(
|
||||||
|
&self,
|
||||||
|
path: impl Into<String>,
|
||||||
|
overwrite: bool,
|
||||||
|
include_project: bool,
|
||||||
|
) -> Result<(), KiCadError> {
|
||||||
|
let _ = self
|
||||||
|
.save_copy_of_document_raw(path, overwrite, include_project)
|
||||||
|
.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