77#![ allow( clippy:: upper_case_acronyms) ]
88
99use clap:: builder:: ValueParser ;
10- use uucore:: LocalizedCommand ;
1110use uucore:: error:: { UResult , USimpleError , UUsageError } ;
1211use uucore:: translate;
1312use uucore:: { display:: Quotable , format_usage, show_error, show_warning} ;
1413
15- use clap:: { Arg , ArgAction , Command } ;
14+ use clap:: { Arg , ArgAction , ArgMatches , Command } ;
1615use selinux:: { OpaqueSecurityContext , SecurityContext } ;
1716
1817use std:: borrow:: Cow ;
@@ -58,9 +57,9 @@ pub mod options {
5857
5958#[ uucore:: main]
6059pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
61- let config = uu_app ( ) ;
60+ let matches = uucore :: clap_localization :: handle_clap_result ( uu_app ( ) , args ) ? ;
6261
63- let options = match parse_command_line ( config , args ) {
62+ let options = match parse_command_line ( & matches ) {
6463 Ok ( r) => r,
6564 Err ( r) => {
6665 if let Error :: CommandLine ( r) = r {
@@ -155,20 +154,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
155154}
156155
157156pub fn uu_app ( ) -> Command {
158- Command :: new ( uucore:: util_name ( ) )
157+ let cmd = Command :: new ( uucore:: util_name ( ) )
159158 . version ( uucore:: crate_version!( ) )
160- . help_template ( uucore:: localized_help_template ( uucore:: util_name ( ) ) )
161159 . about ( translate ! ( "chcon-about" ) )
162160 . override_usage ( format_usage ( & translate ! ( "chcon-usage" ) ) )
163- . infer_long_args ( true )
164- . disable_help_flag ( true )
161+ . infer_long_args ( true ) ;
162+ uucore :: clap_localization :: configure_localized_command ( cmd )
165163 . args_override_self ( true )
166- . arg (
167- Arg :: new ( options:: HELP )
168- . long ( options:: HELP )
169- . help ( translate ! ( "chcon-help-help" ) )
170- . action ( ArgAction :: Help ) ,
171- )
164+ . disable_help_flag ( true )
172165 . arg (
173166 Arg :: new ( options:: dereference:: DEREFERENCE )
174167 . long ( options:: dereference:: DEREFERENCE )
@@ -183,6 +176,12 @@ pub fn uu_app() -> Command {
183176 . help ( translate ! ( "chcon-help-no-dereference" ) )
184177 . action ( ArgAction :: SetTrue ) ,
185178 )
179+ . arg (
180+ Arg :: new ( "help" )
181+ . long ( "help" )
182+ . help ( translate ! ( "help" ) )
183+ . action ( ArgAction :: Help ) ,
184+ )
186185 . arg (
187186 Arg :: new ( options:: preserve_root:: PRESERVE_ROOT )
188187 . long ( options:: preserve_root:: PRESERVE_ROOT )
@@ -304,9 +303,7 @@ struct Options {
304303 files : Vec < PathBuf > ,
305304}
306305
307- fn parse_command_line ( config : Command , args : impl uucore:: Args ) -> Result < Options > {
308- let matches = config. get_matches_from_localized ( args) ;
309-
306+ fn parse_command_line ( matches : & ArgMatches ) -> Result < Options > {
310307 let verbose = matches. get_flag ( options:: VERBOSE ) ;
311308
312309 let ( recursive_mode, affect_symlink_referent) = if matches. get_flag ( options:: RECURSIVE ) {
0 commit comments