55// For the full copyright and license information, please view the LICENSE
66// file that was distributed with this source code.
77
8- use clap:: App ;
9- use clap:: Arg ;
10- use clap:: Shell ;
8+ use clap:: { App , Arg } ;
9+ use clap_complete:: Shell ;
1110use std:: cmp;
1211use std:: collections:: hash_map:: HashMap ;
1312use std:: ffi:: OsStr ;
@@ -143,13 +142,13 @@ fn gen_completions<T: uucore::Args>(
143142 let matches = App :: new ( "completion" )
144143 . about ( "Prints completions to stdout" )
145144 . arg (
146- Arg :: with_name ( "utility" )
147- . possible_values ( & all_utilities)
145+ Arg :: new ( "utility" )
146+ . possible_values ( all_utilities)
148147 . required ( true ) ,
149148 )
150149 . arg (
151- Arg :: with_name ( "shell" )
152- . possible_values ( & Shell :: variants ( ) )
150+ Arg :: new ( "shell" )
151+ . possible_values ( Shell :: possible_values ( ) )
153152 . required ( true ) ,
154153 )
155154 . get_matches_from ( std:: iter:: once ( OsString :: from ( "completion" ) ) . chain ( args) ) ;
@@ -165,12 +164,12 @@ fn gen_completions<T: uucore::Args>(
165164 let shell: Shell = shell. parse ( ) . unwrap ( ) ;
166165 let bin_name = std:: env:: var ( "PROG_PREFIX" ) . unwrap_or_default ( ) + utility;
167166
168- app . gen_completions_to ( bin_name , shell , & mut io:: stdout ( ) ) ;
167+ clap_complete :: generate ( shell , & mut app , bin_name , & mut io:: stdout ( ) ) ;
169168 io:: stdout ( ) . flush ( ) . unwrap ( ) ;
170169 process:: exit ( 0 ) ;
171170}
172171
173- fn gen_coreutils_app < T : uucore:: Args > ( util_map : UtilityMap < T > ) -> App < ' static , ' static > {
172+ fn gen_coreutils_app < T : uucore:: Args > ( util_map : UtilityMap < T > ) -> App < ' static > {
174173 let mut app = App :: new ( "coreutils" ) ;
175174 for ( _, ( _, sub_app) ) in util_map {
176175 app = app. subcommand ( sub_app ( ) ) ;
0 commit comments