File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -691,9 +691,32 @@ See '<cyan,bold>cargo help</> <cyan><<command>></>' for more information on a sp
691691 } ) )
692692 } ) . collect ( )
693693 } ) ) )
694+ . add ( clap_complete:: engine:: SubcommandCandidates :: new ( || {
695+ get_toolchains_from_rustup ( )
696+ . into_iter ( )
697+ . map ( |t| clap_complete:: CompletionCandidate :: new ( t) )
698+ . collect ( )
699+ } ) )
694700 . subcommands ( commands:: builtin ( ) )
695701}
696702
703+ fn get_toolchains_from_rustup ( ) -> Vec < String > {
704+ let output = std:: process:: Command :: new ( "rustup" )
705+ . arg ( "toolchain" )
706+ . arg ( "list" )
707+ . arg ( "-q" )
708+ . output ( )
709+ . unwrap ( ) ;
710+
711+ if !output. status . success ( ) {
712+ return vec ! [ ] ;
713+ }
714+
715+ let stdout = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
716+
717+ stdout. lines ( ) . map ( |line| format ! ( "+{}" , line) ) . collect ( )
718+ }
719+
697720#[ test]
698721fn verify_cli ( ) {
699722 let gctx = GlobalContext :: default ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments