File tree 1 file changed +23
-0
lines changed
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
691
691
} ) )
692
692
} ) . collect ( )
693
693
} ) ) )
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
+ } ) )
694
700
. subcommands ( commands:: builtin ( ) )
695
701
}
696
702
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
+
697
720
#[ test]
698
721
fn verify_cli ( ) {
699
722
let gctx = GlobalContext :: default ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments