This repository was archived by the owner on Feb 21, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,17 +10,20 @@ use directories::ProjectDirs;
1010use log:: error;
1111
1212use crate :: cli_commands:: probe:: ProbeArguments ;
13+ use crate :: cli_commands:: target:: TargetCommmands ;
1314use crate :: { CliArguments , CompletionArguments } ;
1415
1516pub mod probe;
17+ mod target;
1618
1719#[ derive( Subcommand ) ]
1820pub enum ToplevelCommmands
1921{
2022 /// Actions to be performed against a probe
2123 Probe ( ProbeArguments ) ,
2224 /// Actions to be performed against a target connected to a probe
23- Target ,
25+ #[ command( subcommand) ]
26+ Target ( TargetCommmands ) ,
2427 /// Actions that run the tool as a debug/tracing server
2528 Server ,
2629 /// Actions that run debugging commands against a target connected to a probe
Original file line number Diff line number Diff line change 1+ use bmputil:: bmp:: BmpMatcher ;
2+ use clap:: Subcommand ;
3+ use color_eyre:: eyre:: Result ;
4+ use log:: info;
5+
6+ use crate :: CliArguments ;
7+
8+ #[ derive( Subcommand ) ]
9+ #[ command( arg_required_else_help( true ) ) ]
10+ pub enum TargetCommmands
11+ {
12+ /// Print information about the target power control state
13+ Power ,
14+ }
15+
16+ impl TargetCommmands
17+ {
18+ pub fn subcommand ( & self , cli_args : & CliArguments ) -> Result < ( ) >
19+ {
20+ match self {
21+ TargetCommmands :: Power => power_command ( & cli_args) ,
22+ }
23+ }
24+ }
25+
26+ fn power_command ( cli_args : & CliArguments ) -> Result < ( ) >
27+ {
28+ // Try and identify all the probes on the system that are allowed by the invocation
29+ let matcher = BmpMatcher :: from_params ( cli_args) ;
30+ let mut results = matcher. find_matching_probes ( ) ;
31+
32+ // Otherwise, turn the result set into a list and go through them displaying them
33+ let device = results. pop_single ( "power" ) . map_err ( |kind| kind. error ( ) ) ?;
34+ let remote = device. bmd_serial_interface ( ) ?. remote ( ) ?;
35+
36+ let power = remote. get_target_power_state ( ) ?;
37+
38+ info ! ( "Device target power state: {}" , power) ;
39+
40+ Ok ( ( ) )
41+ }
Original file line number Diff line number Diff line change @@ -244,10 +244,7 @@ fn main() -> Result<()>
244244
245245 match & cli_args. subcommand {
246246 ToplevelCommmands :: Probe ( probe_args) => probe_args. subcommand ( & cli_args) ,
247- ToplevelCommmands :: Target => {
248- warn ! ( "Command space reserved for future tool version" ) ;
249- Ok ( ( ) )
250- } ,
247+ ToplevelCommmands :: Target ( target_commands) => target_commands. subcommand ( & cli_args) ,
251248 ToplevelCommmands :: Server => {
252249 warn ! ( "Command space reserved for future tool version" ) ;
253250 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments