1- use crate :: executor:: { ToolInstallStatus , get_all_executors} ;
1+ use crate :: executor:: { ExecutorSupport , ToolInstallStatus , get_all_executors} ;
22use crate :: prelude:: * ;
33use crate :: system:: SystemInfo ;
44use clap:: { Args , Subcommand } ;
@@ -22,10 +22,7 @@ enum SetupCommands {
2222pub async fn run ( args : SetupArgs , setup_cache_dir : Option < & Path > ) -> Result < ( ) > {
2323 match args. command {
2424 None => setup ( setup_cache_dir) . await ,
25- Some ( SetupCommands :: Status ) => {
26- status ( ) ;
27- Ok ( ( ) )
28- }
25+ Some ( SetupCommands :: Status ) => status ( ) ,
2926 }
3027}
3128
@@ -34,41 +31,81 @@ async fn setup(setup_cache_dir: Option<&Path>) -> Result<()> {
3431 let executors = get_all_executors ( ) ;
3532 start_group ! ( "Setting up the environment for all executors" ) ;
3633 for executor in executors {
37- info ! (
38- "Setting up the environment for the executor: {}" ,
39- executor. name( )
40- ) ;
41- executor. setup ( & system_info, setup_cache_dir) . await ?;
34+ match executor. support_level ( & system_info) {
35+ ExecutorSupport :: Unsupported => {
36+ info ! (
37+ "Skipping setup for the {} executor: not supported on {}" ,
38+ executor. name( ) ,
39+ system_info. os
40+ ) ;
41+ }
42+ ExecutorSupport :: RequiresManualInstallation => {
43+ info ! (
44+ "Skipping automatic setup for the {} executor on {}; install required tooling manually." ,
45+ executor. name( ) ,
46+ system_info. os
47+ ) ;
48+ }
49+ ExecutorSupport :: FullySupported => {
50+ info ! (
51+ "Setting up the environment for the executor: {}" ,
52+ executor. name( )
53+ ) ;
54+ executor. setup ( & system_info, setup_cache_dir) . await ?;
55+ }
56+ }
4257 }
4358 info ! ( "Environment setup completed" ) ;
4459 end_group ! ( ) ;
4560 Ok ( ( ) )
4661}
4762
48- pub fn status ( ) {
63+ pub fn status ( ) -> Result < ( ) > {
64+ let system_info = SystemInfo :: new ( ) ?;
4965 info ! ( "{}" , style( "Tools" ) . bold( ) ) ;
5066 for executor in get_all_executors ( ) {
51- let tool_status = executor. tool_status ( ) ;
52- match & tool_status. status {
53- ToolInstallStatus :: Installed { version } => {
54- info ! ( " {} {} ({})" , check_mark( ) , tool_status. tool_name, version) ;
55- }
56- ToolInstallStatus :: IncorrectVersion { version, message } => {
57- info ! (
58- " {} {} ({}, {})" ,
59- warn_mark( ) ,
60- tool_status. tool_name,
61- version,
62- message
63- ) ;
64- }
65- ToolInstallStatus :: NotInstalled => {
67+ // Don't probe for tooling that can't be used on this OS anyway.
68+ if executor. support_level ( & system_info) == ExecutorSupport :: Unsupported {
69+ continue ;
70+ }
71+ match executor. tool_status ( ) {
72+ Some ( tool_status) => match & tool_status. status {
73+ ToolInstallStatus :: Installed { version } => {
74+ info ! (
75+ " {} {} executor: {} ({})" ,
76+ check_mark( ) ,
77+ executor. name( ) ,
78+ tool_status. tool_name,
79+ version
80+ ) ;
81+ }
82+ ToolInstallStatus :: IncorrectVersion { version, message } => {
83+ info ! (
84+ " {} {} executor: {} ({}, {})" ,
85+ warn_mark( ) ,
86+ executor. name( ) ,
87+ tool_status. tool_name,
88+ version,
89+ message
90+ ) ;
91+ }
92+ ToolInstallStatus :: NotInstalled => {
93+ info ! (
94+ " {} {} executor: {} (not installed)" ,
95+ cross_mark( ) ,
96+ executor. name( ) ,
97+ tool_status. tool_name
98+ ) ;
99+ }
100+ } ,
101+ None => {
66102 info ! (
67- " {} {} (not installed) " ,
68- cross_mark ( ) ,
69- tool_status . tool_name
103+ " {} {} executor: No tool to install " ,
104+ check_mark ( ) ,
105+ executor . name ( )
70106 ) ;
71107 }
72108 }
73109 }
110+ Ok ( ( ) )
74111}
0 commit comments