1- use crate :: efivar:: print_mode:: { Decimal , Verbose } ;
2- use crate :: efivar:: types:: PrintMode ;
3- use clap;
4- use efivar;
1+ use efivar:: {
2+ self ,
3+ print_mode:: { Decimal , Verbose } ,
4+ types:: PrintMode ,
5+ } ;
56use ignore_result:: Ignore ;
67use std:: io;
78use std:: process:: ExitCode ;
89
910fn create_parser ( ) -> clap:: Command {
10- return clap:: Command :: new ( "efivar" )
11+ clap:: Command :: new ( "efivar" )
1112 . args_override_self ( true )
1213 . disable_help_flag ( true )
1314 . disable_version_flag ( true )
@@ -82,7 +83,7 @@ fn create_parser() -> clap::Command {
8283 . long ( "guids-list-path" )
8384 . value_name ( "guids-list-path" )
8485 . default_value ( efivar:: efi_guids:: DEFAULT_GUIDS_LIST_PATH )
85- . help ( format ! ( "specify path to GUIDs list file." ) )
86+ . help ( "specify path to GUIDs list file." . to_string ( ) )
8687 . action ( clap:: ArgAction :: Set )
8788 )
8889 . arg ( clap:: Arg :: new ( "list-guids" )
@@ -108,7 +109,7 @@ fn create_parser() -> clap::Command {
108109 . long ( "usage" )
109110 . help ( "ignored for compatibility" )
110111 . action ( clap:: ArgAction :: Help )
111- ) ;
112+ )
112113}
113114
114115fn list_variables ( _parser_args : clap:: ArgMatches ) -> ExitCode {
@@ -120,7 +121,7 @@ fn list_variables(_parser_args: clap::ArgMatches) -> ExitCode {
120121 for v in variables {
121122 println ! ( "{}" , v) ;
122123 }
123- return std:: process:: ExitCode :: from ( 0 ) ;
124+ std:: process:: ExitCode :: from ( 0 )
124125 }
125126 Err ( _) => {
126127 let efivar_variables: efivar:: efivar:: EfiVariables =
@@ -130,11 +131,11 @@ fn list_variables(_parser_args: clap::ArgMatches) -> ExitCode {
130131 for v in variables {
131132 println ! ( "{}" , v) ;
132133 }
133- return std:: process:: ExitCode :: from ( 0 ) ;
134+ std:: process:: ExitCode :: from ( 0 )
134135 }
135136 Err ( e) => {
136137 eprintln ! ( "Failed to access EFI variables: {}" , e) ;
137- return std:: process:: ExitCode :: from ( 1 ) ;
138+ std:: process:: ExitCode :: from ( 1 )
138139 }
139140 }
140141 }
@@ -152,7 +153,7 @@ fn print_variable(parser_args: clap::ArgMatches, print_mode: efivar::types::Prin
152153 PrintMode :: VERBOSE => println ! ( "{}" , Verbose ( & var) ) ,
153154 PrintMode :: DECIMAL => println ! ( "{}" , Decimal ( & var) ) ,
154155 }
155- return std:: process:: ExitCode :: from ( 0 ) ;
156+ std:: process:: ExitCode :: from ( 0 )
156157 }
157158 Err ( _) => {
158159 let efivar_variables: efivar:: efivar:: EfiVariables =
@@ -163,25 +164,25 @@ fn print_variable(parser_args: clap::ArgMatches, print_mode: efivar::types::Prin
163164 PrintMode :: VERBOSE => println ! ( "{}" , Verbose ( & var) ) ,
164165 PrintMode :: DECIMAL => println ! ( "{}" , Decimal ( & var) ) ,
165166 }
166- return std:: process:: ExitCode :: from ( 0 ) ;
167+ std:: process:: ExitCode :: from ( 0 )
167168 }
168169 Err ( e) => {
169170 eprintln ! ( "Failed to read variable: {}" , e) ;
170- return std:: process:: ExitCode :: from ( 1 ) ;
171+ std:: process:: ExitCode :: from ( 1 )
171172 }
172173 }
173174 }
174- } ;
175+ }
175176 }
176177 None => {
177178 eprintln ! ( "No variable name given" ) ;
178- return std:: process:: ExitCode :: from ( 1 ) ;
179+ std:: process:: ExitCode :: from ( 1 )
179180 }
180- } ;
181+ }
181182}
182183
183184fn append_attributes ( parser_args : clap:: ArgMatches ) -> ExitCode {
184- return std:: process:: ExitCode :: from ( 0 ) ;
185+ std:: process:: ExitCode :: from ( 0 )
185186}
186187
187188fn list_guids ( parser_args : clap:: ArgMatches ) -> ExitCode {
@@ -197,46 +198,44 @@ fn list_guids(parser_args: clap::ArgMatches) -> ExitCode {
197198 return std:: process:: ExitCode :: from ( e. raw_os_error ( ) . unwrap_or ( 1 ) as u8 ) ;
198199 }
199200 }
200- return std:: process:: ExitCode :: from ( 0 ) ;
201+ std:: process:: ExitCode :: from ( 0 )
201202}
202203
203204fn write_variable ( parser_args : clap:: ArgMatches ) -> ExitCode {
204- return std:: process:: ExitCode :: from ( 0 ) ;
205+ std:: process:: ExitCode :: from ( 0 )
205206}
206207
207208fn import_variable ( parser_args : clap:: ArgMatches ) -> ExitCode {
208- return std:: process:: ExitCode :: from ( 0 ) ;
209+ std:: process:: ExitCode :: from ( 0 )
209210}
210211
211212fn export_variable ( parser_args : clap:: ArgMatches ) -> ExitCode {
212- return std:: process:: ExitCode :: from ( 0 ) ;
213+ std:: process:: ExitCode :: from ( 0 )
213214}
214215
215216fn main ( ) -> ExitCode {
216217 let mut parser = create_parser ( ) ;
217218 let matches = parser. get_matches_mut ( ) ;
218219 if matches. get_flag ( "list" ) {
219- return list_variables ( matches) ;
220+ list_variables ( matches)
220221 } else if matches. get_flag ( "print" ) {
221- return print_variable ( matches, efivar:: types:: PrintMode :: VERBOSE ) ;
222+ print_variable ( matches, efivar:: types:: PrintMode :: VERBOSE )
222223 } else if matches. get_flag ( "append" ) {
223- return append_attributes ( matches) ;
224+ append_attributes ( matches)
224225 } else if matches. get_flag ( "list-guids" ) {
225- return list_guids ( matches) ;
226+ list_guids ( matches)
226227 } else if matches. get_flag ( "write" ) {
227- return write_variable ( matches) ;
228+ write_variable ( matches)
228229 } else if matches. get_flag ( "print-decimal" ) {
229- return print_variable ( matches, efivar:: types:: PrintMode :: DECIMAL ) ;
230+ print_variable ( matches, efivar:: types:: PrintMode :: DECIMAL )
230231 } else if matches. get_one :: < & str > ( "import" ) . is_some ( ) {
231- return import_variable ( matches) ;
232+ import_variable ( matches)
232233 } else if matches. get_one :: < & str > ( "export" ) . is_some ( ) {
233- return export_variable ( matches) ;
234+ export_variable ( matches)
235+ } else if matches. get_one :: < String > ( "name" ) . is_some ( ) {
236+ return print_variable ( matches, efivar:: types:: PrintMode :: VERBOSE ) ;
234237 } else {
235- if matches. get_one :: < String > ( "name" ) . is_some ( ) {
236- return print_variable ( matches, efivar:: types:: PrintMode :: VERBOSE ) ;
237- } else {
238- parser. write_help ( & mut io:: stderr ( ) ) . ignore ( ) ;
239- return std:: process:: ExitCode :: from ( 1 ) ;
240- }
238+ parser. write_help ( & mut io:: stderr ( ) ) . ignore ( ) ;
239+ return std:: process:: ExitCode :: from ( 1 ) ;
241240 }
242241}
0 commit comments