File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,9 @@ struct EspFlashOpts {
53
53
54
54
#[ derive( Parser ) ]
55
55
pub enum SubCommand {
56
+ /// Display information about the connected board and exit without flashing
56
57
BoardInfo ( ConnectOpts ) ,
58
+ /// Save the image to disk instead of flashing to device
57
59
SaveImage ( SaveImageOpts ) ,
58
60
}
59
61
@@ -82,7 +84,6 @@ pub struct BuildOpts {
82
84
pub unstable : Option < Vec < String > > ,
83
85
}
84
86
85
- /// Save the image to disk instead of flashing to device
86
87
#[ derive( Parser ) ]
87
88
pub struct SaveImageOpts {
88
89
#[ clap( flatten) ]
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ pub fn get_serial_port_info(
64
64
fn find_serial_port ( ports : & [ SerialPortInfo ] , name : String ) -> Option < SerialPortInfo > {
65
65
ports
66
66
. iter ( )
67
- . find ( |port| port. port_name == name)
67
+ . find ( |port| port. port_name . to_lowercase ( ) == name. to_lowercase ( ) )
68
68
. map ( |port| port. to_owned ( ) )
69
69
}
70
70
Original file line number Diff line number Diff line change @@ -28,11 +28,12 @@ struct Opts {
28
28
29
29
#[ derive( Parser ) ]
30
30
pub enum SubCommand {
31
+ /// Display information about the connected board and exit without flashing
31
32
BoardInfo ( ConnectOpts ) ,
33
+ /// Save the image to disk instead of flashing to device
32
34
SaveImage ( SaveImageOpts ) ,
33
35
}
34
36
35
- /// Save the image to disk instead of flashing to device
36
37
#[ derive( Parser ) ]
37
38
pub struct SaveImageOpts {
38
39
/// Image format to flash
@@ -52,8 +53,15 @@ fn main() -> Result<()> {
52
53
let mut opts = Opts :: parse ( ) ;
53
54
let config = Config :: load ( ) ?;
54
55
55
- // If only a single argument is passed, it's always going to be the ELF file. In
56
- // the case that the serial port was not provided as a command-line argument,
56
+ // If neither the IMAGE nor SERIAL arguments have been provided, print the help
57
+ // message and exit.
58
+ if opts. image . is_none ( ) && opts. connect_opts . serial . is_none ( ) {
59
+ Opts :: into_app ( ) . print_help ( ) . ok ( ) ;
60
+ return Ok ( ( ) ) ;
61
+ }
62
+
63
+ // If only a single argument is passed, it *should* always be the ELF file.
64
+ // In the case that the serial port was not provided as a command-line argument,
57
65
// we will either load the value specified in the configuration file or do port
58
66
// auto-detection instead.
59
67
if opts. image . is_none ( ) && opts. connect_opts . serial . is_some ( ) {
You can’t perform that action at this time.
0 commit comments