-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
115 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
on: [push] | ||
on: [push, pull_request] | ||
|
||
name: build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,60 @@ | ||
use std::env; | ||
use clap::Parser; | ||
use std::env; | ||
|
||
mod system_profiler; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Args { | ||
/// Attempt to maintain compatibility with lsusb output | ||
#[arg(short, long, default_value_t = false)] | ||
lsusb: bool, | ||
/// Attempt to maintain compatibility with lsusb output | ||
#[arg(short, long, default_value_t = false)] | ||
lsusb: bool, | ||
|
||
/// Disable coloured output, can also use NO_COLOR environment variable | ||
#[arg(short, long, default_value_t = false)] | ||
no_colour: bool, | ||
/// Disable coloured output, can also use NO_COLOR environment variable | ||
#[arg(short, long, default_value_t = false)] | ||
no_colour: bool, | ||
|
||
/// Dump the physical USB device hierarchy as a tree | ||
#[arg(short, long, default_value_t = false)] | ||
tree: bool, | ||
/// Classic dump the physical USB device hierarchy as a tree | ||
#[arg(short = 't', long, default_value_t = false)] | ||
lsusb_tree: bool, | ||
|
||
/// Show only devices with the specified vendor and product ID numbers (in hexadecimal) in format VID:[PID] | ||
#[arg(short, long)] | ||
device: Option<String>, | ||
/// Modern dump the physical USB device hierarchy as a tree | ||
#[arg(short = 'T', long, default_value_t = true)] | ||
tree: bool, | ||
|
||
/// Show only devices with specified device and/or bus numbers (in decimal) in format [[bus]:][devnum] | ||
#[arg(short, long)] | ||
show: Option<String>, | ||
/// Show only devices with the specified vendor and product ID numbers (in hexadecimal) in format VID:[PID] | ||
#[arg(short, long)] | ||
device: Option<String>, | ||
|
||
/// Increase verbosity (show descriptors) | ||
#[arg(short, long, default_value_t = false)] | ||
verbose: bool, | ||
} | ||
/// Show only devices with specified device and/or bus numbers (in decimal) in format [[bus]:][devnum] | ||
#[arg(short, long)] | ||
show: Option<String>, | ||
|
||
mod system_profiler; | ||
/// Increase verbosity (show descriptors) | ||
#[arg(short, long, default_value_t = false)] | ||
verbose: bool, | ||
} | ||
|
||
fn main() { | ||
let args = Args::parse(); | ||
let sp_usb = system_profiler::get_spusb().unwrap(); | ||
|
||
// just set the env for this process | ||
if args.no_colour { | ||
env::set_var("NO_COLOR", "1"); | ||
} | ||
|
||
if args.lsusb { | ||
if args.tree { | ||
print!("{:+}", sp_usb); | ||
} else { | ||
print!("{:}", sp_usb); | ||
} | ||
} else { | ||
if args.tree { | ||
print!("{:+#}", sp_usb); | ||
} else { | ||
print!("{:#}", sp_usb); | ||
} | ||
} | ||
let args = Args::parse(); | ||
let sp_usb = system_profiler::get_spusb().unwrap(); | ||
|
||
// just set the env for this process | ||
if args.no_colour { | ||
env::set_var("NO_COLOR", "1"); | ||
} | ||
|
||
if args.lsusb { | ||
if args.lsusb_tree { | ||
print!("{:+}", sp_usb); | ||
} else { | ||
print!("{:}", sp_usb); | ||
} | ||
} else { | ||
if args.tree { | ||
print!("{:+#}", sp_usb); | ||
} else { | ||
print!("{:#}", sp_usb); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters