1- extern crate efivar;
2-
31use clap;
4- use efivar:: { efivar_display, efi_variable_attributes} ;
5- use std:: collections:: HashSet ;
6- use std:: convert:: TryInto ;
2+ use efivar:: { efi_guids, efi_variable_attributes, efivar_display} ;
73use std:: process:: ExitCode ;
84
9- #[ derive( Eq , Hash , PartialEq ) ]
10- enum ActionType {
11- Append ,
12- Export ,
13- Import ,
14- List ,
15- ListGuids ,
16- Print ,
17- Write
18- }
19-
20- #[ derive( Eq , Hash , PartialEq ) ]
21- struct EfivarAction ( ActionType ) ;
22-
23- fn main ( ) -> ExitCode {
24- let parser = clap:: command!( )
5+ fn create_parser ( ) -> clap:: Command {
6+ return clap:: command!( )
257 . args_override_self ( true )
268 . disable_help_flag ( true )
279 . disable_version_flag ( true )
@@ -37,7 +19,7 @@ fn main() -> ExitCode {
3719 . short ( 'l' )
3820 . long ( "list" )
3921 . help ( "list current variables" )
40- . action ( clap:: ArgAction :: Set )
22+ . action ( clap:: ArgAction :: SetTrue )
4123 )
4224 . arg ( clap:: Arg :: new ( "print" )
4325 . short ( 'p' )
@@ -114,7 +96,21 @@ fn main() -> ExitCode {
11496 . long ( "usage" )
11597 . help ( "ignored for compatibility" )
11698 . action ( clap:: ArgAction :: Help )
117- )
118- . get_matches ( ) ;
99+ ) ;
100+ }
101+
102+ fn main ( ) -> ExitCode {
103+ let matches = create_parser ( ) . get_matches ( ) ;
104+ if matches. get_flag ( "list-guids" ) {
105+ for g in efi_guids:: EFI_WELL_KNOWN_GUIDS
106+ . sort_by_guid ( )
107+ . split_last ( )
108+ . unwrap ( )
109+ . 1
110+ . iter ( )
111+ {
112+ print ! ( "{}" , g) ;
113+ }
114+ }
119115 return std:: process:: ExitCode :: from ( 0 ) ;
120116}
0 commit comments