File tree Expand file tree Collapse file tree 2 files changed +16
-48
lines changed Expand file tree Collapse file tree 2 files changed +16
-48
lines changed Original file line number Diff line number Diff line change 11#![ feature( exitcode_exit_method) ]
22
3- use std:: {
4- io:: { Write , stdout} ,
5- os:: unix:: ffi:: OsStrExt ,
6- process:: ExitCode ,
7- } ;
3+ use std:: { io:: stdout, process:: ExitCode } ;
84
9- use coreutils:: { Result , help_text, version_text} ;
10-
11- const VERSION : & str = version_text ! ( "false" ) ;
12- const HELP : & str = help_text ! ( "false" ) ;
5+ use coreutils:: { Result , cli_with_args} ;
6+ use sap:: Parser ;
137
148fn main ( ) -> Result {
15- let mut args = std:: env:: args_os ( ) ;
9+ let args = std:: env:: args_os ( ) ;
1610
1711 if args. len ( ) == 2 {
18- args. next ( ) ;
19- if let Some ( arg) = args. next ( ) {
20- match arg. as_bytes ( ) {
21- b"--version" => {
22- stdout ( ) . write_all ( VERSION . as_bytes ( ) ) ?;
23- return Ok ( ( ) ) ;
24- }
25- b"--help" => {
26- stdout ( ) . write_all ( HELP . as_bytes ( ) ) ?;
27- return Ok ( ( ) ) ;
28- }
29- _ => { }
30- }
31- }
12+ let mut stdout = stdout ( ) ;
13+ let mut args_parser = Parser :: from_arbitrary ( args) ?;
14+
15+ cli_with_args ! ( args_parser, "false" , stdout, #ignore) ;
3216 }
3317
3418 ExitCode :: FAILURE . exit_process ( )
Original file line number Diff line number Diff line change 1- use std:: {
2- io:: { Write , stdout} ,
3- os:: unix:: ffi:: OsStrExt ,
4- } ;
5-
6- use coreutils:: { Result , help_text, version_text} ;
7-
8- const VERSION : & str = version_text ! ( "true" ) ;
9- const HELP : & str = help_text ! ( "true" ) ;
1+ use coreutils:: { Result , cli_with_args} ;
2+ use sap:: Parser ;
3+ use std:: io:: stdout;
104
115fn main ( ) -> Result {
12- let mut args = std:: env:: args_os ( ) ;
6+ let args = std:: env:: args_os ( ) ;
137
148 if args. len ( ) == 2 {
15- args. next ( ) ;
16- if let Some ( arg) = args. next ( ) {
17- match arg. as_bytes ( ) {
18- b"--version" => {
19- stdout ( ) . write_all ( VERSION . as_bytes ( ) ) ?;
20- return Ok ( ( ) ) ;
21- }
22- b"--help" => {
23- stdout ( ) . write_all ( HELP . as_bytes ( ) ) ?;
24- return Ok ( ( ) ) ;
25- }
26- _ => { }
27- }
28- }
9+ let mut stdout = stdout ( ) ;
10+ let mut args_parser = Parser :: from_arbitrary ( args) ?;
11+
12+ cli_with_args ! ( args_parser, "true" , stdout, #ignore) ;
2913 }
3014
3115 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments