|
| 1 | +// TODO: Add doctest for commands from readme |
| 2 | +// const CLI_COMMAND: &str = "unprotect ble-update --file stack.bin --address 0x123 flash-bin --file app.bin --address 0x456 protect reset"; |
| 3 | + |
| 4 | +// // Include the command in the docstring dynamically |
| 5 | +// #[doc = concat!( |
| 6 | +// "Example usage of the CLI.\n\n", |
| 7 | +// "```sh\n", |
| 8 | +// "my_cli_tool ", CLI_COMMAND, "\n", |
| 9 | +// "```\n\n", |
| 10 | +// "(The following test is hidden from the documentation.)" |
| 11 | +// )] |
| 12 | +// /// |
| 13 | +// /// ``` |
| 14 | +// /// # use my_crate::{options, TargetCommand, BleStackInfo, BinFileInfo, HexAddress, ResetMode}; |
| 15 | +// /// # use std::path::PathBuf; |
| 16 | +// /// # std::env::set_var("STM32_CUBE_PROGRAMMER_DIR", "some/dir"); |
| 17 | +// /// |
| 18 | +// /// // Use the same command string in the test |
| 19 | +// /// let command = CLI_COMMAND; |
| 20 | +// /// |
| 21 | +// /// // Run the CLI parsing logic |
| 22 | +// /// let value = options() |
| 23 | +// /// .run_inner(command.split(' ').collect::<Vec<_>>().as_slice()) |
| 24 | +// /// .unwrap(); |
| 25 | +// /// ``` |
| 26 | +// #[derive(Default)] |
| 27 | +// /// Track the connection state of the programmer |
| 28 | +// enum ConnectionState<'a> { |
| 29 | +// #[default] |
| 30 | +// Disconnected, |
| 31 | +// Connected(Option<stm32cubeprogrammer::ConnectedProgrammer<'a>>), |
| 32 | +// ConnectedFus(Option<stm32cubeprogrammer::ConnectedFusProgrammer<'a>>), |
| 33 | +// } |
| 34 | + |
1 | 35 | //! This CLI aims to provide a simple interface for setting up stm32 targets.
|
2 | 36 | //! # Supported commands
|
3 | 37 | //! - Flashing bin and hex files
|
@@ -57,14 +91,8 @@ use log::{error, info};
|
57 | 91 | use std::sync::Mutex;
|
58 | 92 | use stm32cubeprogrammer::probe;
|
59 | 93 |
|
60 |
| -#[derive(Default)] |
61 |
| -/// Track the connection state of the programmer |
62 |
| -enum ConnectionState<'a> { |
63 |
| - #[default] |
64 |
| - Disconnected, |
65 |
| - Connected(Option<stm32cubeprogrammer::ConnectedProgrammer<'a>>), |
66 |
| - ConnectedFus(Option<stm32cubeprogrammer::ConnectedFusProgrammer<'a>>), |
67 |
| -} |
| 94 | + |
| 95 | + |
68 | 96 |
|
69 | 97 | /// Helper struct to manage the programmer connection
|
70 | 98 | struct ProgrammerConnection<'a> {
|
@@ -264,7 +292,7 @@ fn main_inner() -> Result<crate::output::Output, anyhow::Error> {
|
264 | 292 | if options
|
265 | 293 | .target_commands
|
266 | 294 | .iter()
|
267 |
| - .any(|command| matches!(command, parse::TargetCommand::UpdateBleStack(_))) |
| 295 | + .any(|command| matches!(command, parse::TargetCommand::BleUpdate(_))) |
268 | 296 | && !programmer_connection
|
269 | 297 | .connection()?
|
270 | 298 | .general_information()
|
@@ -310,7 +338,7 @@ fn main_inner() -> Result<crate::output::Output, anyhow::Error> {
|
310 | 338 |
|
311 | 339 | output::CommandOutput::FlashHex { file }
|
312 | 340 | }
|
313 |
| - parse::TargetCommand::UpdateBleStack(ble_stack_info) => { |
| 341 | + parse::TargetCommand::BleUpdate(ble_stack_info) => { |
314 | 342 | log::info!("Update BLE stack: {}", ble_stack_info);
|
315 | 343 |
|
316 | 344 | display_handler
|
@@ -363,7 +391,7 @@ fn main_inner() -> Result<crate::output::Output, anyhow::Error> {
|
363 | 391 | .unwrap_or(output::BleStackUpdated::NotUpdated),
|
364 | 392 | }
|
365 | 393 | }
|
366 |
| - parse::TargetCommand::BleStackInfo { compare } => { |
| 394 | + parse::TargetCommand::BleInfo { compare } => { |
367 | 395 | display_handler
|
368 | 396 | .lock()
|
369 | 397 | .unwrap()
|
|
0 commit comments