@@ -87,7 +87,7 @@ impl From<OutputLogsMode> for turborepo_ui::tui::event::OutputLogs {
87
87
}
88
88
}
89
89
90
- #[ derive( Copy , Clone , Debug , PartialEq , Serialize , ValueEnum ) ]
90
+ #[ derive( Copy , Clone , Debug , PartialEq , Serialize , ValueEnum , Deserialize , Eq ) ]
91
91
pub enum LogOrder {
92
92
#[ serde( rename = "auto" ) ]
93
93
Auto ,
@@ -233,7 +233,9 @@ pub struct Args {
233
233
// This should be inside `RunArgs` but clap currently has a bug
234
234
// around nested flattened optional args: https://github.com/clap-rs/clap/issues/4697
235
235
#[ clap( flatten) ]
236
- pub execution_args : Option < ExecutionArgs > ,
236
+ // DO NOT MAKE THIS VISIBLE
237
+ // Instead use the getter method execution_args()
238
+ execution_args : Option < ExecutionArgs > ,
237
239
#[ clap( subcommand) ]
238
240
pub command : Option < Command > ,
239
241
}
@@ -474,6 +476,15 @@ impl Args {
474
476
self . run_args . as_ref ( )
475
477
}
476
478
}
479
+
480
+ /// Fetch the execution args supplied to the command
481
+ pub fn execution_args ( & self ) -> Option < & ExecutionArgs > {
482
+ if let Some ( Command :: Run { execution_args, .. } ) = & self . command {
483
+ Some ( execution_args)
484
+ } else {
485
+ self . execution_args . as_ref ( )
486
+ }
487
+ }
477
488
}
478
489
479
490
/// Defines the subcommands for CLI. NOTE: If we change the commands in Go,
@@ -710,7 +721,7 @@ ArgGroup::new("scope-filter-group").multiple(true).required(false),
710
721
] ) ]
711
722
pub struct ExecutionArgs {
712
723
/// Override the filesystem cache directory.
713
- #[ clap( long, value_parser = path_non_empty, env = "TURBO_CACHE_DIR" ) ]
724
+ #[ clap( long, value_parser = path_non_empty) ]
714
725
pub cache_dir : Option < Utf8PathBuf > ,
715
726
/// Limit the concurrency of task execution. Use 1 for serial (i.e.
716
727
/// one-at-a-time) execution.
@@ -724,7 +735,7 @@ pub struct ExecutionArgs {
724
735
#[ clap( long) ]
725
736
pub single_package : bool ,
726
737
/// Ignore the existing cache (to force execution)
727
- #[ clap( long, env = "TURBO_FORCE" , default_missing_value = "true" ) ]
738
+ #[ clap( long, default_missing_value = "true" ) ]
728
739
pub force : Option < Option < bool > > ,
729
740
/// Specify whether or not to do framework inference for tasks
730
741
#[ clap( long, value_name = "BOOL" , action = ArgAction :: Set , default_value = "true" , default_missing_value = "true" , num_args = 0 ..=1 ) ]
@@ -761,17 +772,17 @@ pub struct ExecutionArgs {
761
772
/// output as soon as it is available. Use "grouped" to
762
773
/// show output when a command has finished execution. Use "auto" to let
763
774
/// turbo decide based on its own heuristics. (default auto)
764
- #[ clap( long, env = "TURBO_LOG_ORDER" , value_enum, default_value_t = LogOrder :: Auto ) ]
765
- pub log_order : LogOrder ,
775
+ #[ clap( long, value_enum) ]
776
+ pub log_order : Option < LogOrder > ,
766
777
/// Only executes the tasks specified, does not execute parent tasks.
767
778
#[ clap( long) ]
768
779
pub only : bool ,
769
780
#[ clap( long, hide = true ) ]
770
781
pub pkg_inference_root : Option < String > ,
771
782
/// Ignore the local filesystem cache for all tasks. Only
772
783
/// allow reading and caching artifacts using the remote cache.
773
- #[ clap( long, env = "TURBO_REMOTE_ONLY" , value_name = "BOOL" , action = ArgAction :: Set , default_value = "false" , default_missing_value = "true" , num_args = 0 ..= 1 ) ]
774
- pub remote_only : bool ,
784
+ #[ clap( long, default_missing_value = "true" ) ]
785
+ pub remote_only : Option < Option < bool > > ,
775
786
/// Use "none" to remove prefixes from task logs. Use "task" to get task id
776
787
/// prefixing. Use "auto" to let turbo decide how to prefix the logs
777
788
/// based on the execution environment. In most cases this will be the same
@@ -790,14 +801,19 @@ pub struct ExecutionArgs {
790
801
}
791
802
792
803
impl ExecutionArgs {
804
+ pub fn remote_only ( & self ) -> Option < bool > {
805
+ let remote_only = self . remote_only ?;
806
+ Some ( remote_only. unwrap_or ( true ) )
807
+ }
808
+
793
809
fn track ( & self , telemetry : & CommandEventBuilder ) {
794
810
// default to false
795
811
track_usage ! ( telemetry, self . framework_inference, |val: bool | !val) ;
796
812
797
813
track_usage ! ( telemetry, self . continue_execution, |val| val) ;
798
814
track_usage ! ( telemetry, self . single_package, |val| val) ;
799
815
track_usage ! ( telemetry, self . only, |val| val) ;
800
- track_usage ! ( telemetry, self . remote_only, |val| val) ;
816
+ track_usage ! ( telemetry, self . remote_only( ) . unwrap_or_default ( ) , |val| val) ;
801
817
track_usage ! ( telemetry, & self . cache_dir, Option :: is_some) ;
802
818
track_usage ! ( telemetry, & self . force, Option :: is_some) ;
803
819
track_usage ! ( telemetry, & self . pkg_inference_root, Option :: is_some) ;
@@ -822,8 +838,8 @@ impl ExecutionArgs {
822
838
telemetry. track_arg_value ( "output-logs" , output_logs, EventType :: NonSensitive ) ;
823
839
}
824
840
825
- if self . log_order != LogOrder :: default ( ) {
826
- telemetry. track_arg_value ( "log-order" , self . log_order , EventType :: NonSensitive ) ;
841
+ if let Some ( log_order) = self . log_order {
842
+ telemetry. track_arg_value ( "log-order" , log_order, EventType :: NonSensitive ) ;
827
843
}
828
844
829
845
if self . log_prefix != LogPrefix :: default ( ) {
@@ -882,10 +898,10 @@ pub struct RunArgs {
882
898
#[ clap( long, value_parser=NonEmptyStringValueParser :: new( ) , conflicts_with = "profile" ) ]
883
899
pub anon_profile : Option < String > ,
884
900
/// Treat remote cache as read only
885
- #[ clap( long, env = "TURBO_REMOTE_CACHE_READ_ONLY" , value_name = "BOOL" , action = ArgAction :: Set , default_value = "false" , default_missing_value = "true" , num_args = 0 ..= 1 ) ]
886
- pub remote_cache_read_only : bool ,
901
+ #[ clap( long, default_missing_value = "true" ) ]
902
+ pub remote_cache_read_only : Option < Option < bool > > ,
887
903
/// Generate a summary of the turbo run
888
- #[ clap( long, env = "TURBO_RUN_SUMMARY" , default_missing_value = "true" ) ]
904
+ #[ clap( long, default_missing_value = "true" ) ]
889
905
pub summarize : Option < Option < bool > > ,
890
906
891
907
// Pass a string to enable posting Run Summaries to Vercel
@@ -908,7 +924,7 @@ impl Default for RunArgs {
908
924
no_daemon : false ,
909
925
profile : None ,
910
926
anon_profile : None ,
911
- remote_cache_read_only : false ,
927
+ remote_cache_read_only : None ,
912
928
summarize : None ,
913
929
experimental_space_id : None ,
914
930
parallel : false ,
@@ -938,13 +954,27 @@ impl RunArgs {
938
954
}
939
955
}
940
956
957
+ pub fn remote_cache_read_only ( & self ) -> Option < bool > {
958
+ let remote_cache_read_only = self . remote_cache_read_only ?;
959
+ Some ( remote_cache_read_only. unwrap_or ( true ) )
960
+ }
961
+
962
+ pub fn summarize ( & self ) -> Option < bool > {
963
+ let summarize = self . summarize ?;
964
+ Some ( summarize. unwrap_or ( true ) )
965
+ }
966
+
941
967
pub fn track ( & self , telemetry : & CommandEventBuilder ) {
942
968
// default to true
943
969
track_usage ! ( telemetry, self . no_cache, |val| val) ;
944
970
track_usage ! ( telemetry, self . daemon, |val| val) ;
945
971
track_usage ! ( telemetry, self . no_daemon, |val| val) ;
946
972
track_usage ! ( telemetry, self . parallel, |val| val) ;
947
- track_usage ! ( telemetry, self . remote_cache_read_only, |val| val) ;
973
+ track_usage ! (
974
+ telemetry,
975
+ self . remote_cache_read_only( ) . unwrap_or_default( ) ,
976
+ |val| val
977
+ ) ;
948
978
949
979
// default to None
950
980
track_usage ! ( telemetry, & self . profile, Option :: is_some) ;
@@ -1412,7 +1442,7 @@ mod test {
1412
1442
fn get_default_execution_args ( ) -> ExecutionArgs {
1413
1443
ExecutionArgs {
1414
1444
output_logs : None ,
1415
- remote_only : false ,
1445
+ remote_only : None ,
1416
1446
framework_inference : true ,
1417
1447
..ExecutionArgs :: default ( )
1418
1448
}
@@ -1923,7 +1953,7 @@ mod test {
1923
1953
command: Some ( Command :: Run {
1924
1954
execution_args: Box :: new( ExecutionArgs {
1925
1955
tasks: vec![ "build" . to_string( ) ] ,
1926
- log_order: LogOrder :: Stream ,
1956
+ log_order: Some ( LogOrder :: Stream ) ,
1927
1957
..get_default_execution_args( )
1928
1958
} ) ,
1929
1959
run_args: Box :: new( get_default_run_args( ) )
@@ -1938,7 +1968,7 @@ mod test {
1938
1968
command: Some ( Command :: Run {
1939
1969
execution_args: Box :: new( ExecutionArgs {
1940
1970
tasks: vec![ "build" . to_string( ) ] ,
1941
- log_order: LogOrder :: Grouped ,
1971
+ log_order: Some ( LogOrder :: Grouped ) ,
1942
1972
..get_default_execution_args( )
1943
1973
} ) ,
1944
1974
run_args: Box :: new( get_default_run_args( ) )
@@ -1998,7 +2028,6 @@ mod test {
1998
2028
command: Some ( Command :: Run {
1999
2029
execution_args: Box :: new( ExecutionArgs {
2000
2030
tasks: vec![ "build" . to_string( ) ] ,
2001
- log_order: LogOrder :: Auto ,
2002
2031
..get_default_execution_args( )
2003
2032
} ) ,
2004
2033
run_args: Box :: new( get_default_run_args( ) )
@@ -2048,7 +2077,7 @@ mod test {
2048
2077
command: Some ( Command :: Run {
2049
2078
execution_args: Box :: new( ExecutionArgs {
2050
2079
tasks: vec![ "build" . to_string( ) ] ,
2051
- remote_only: false ,
2080
+ remote_only: None ,
2052
2081
..get_default_execution_args( )
2053
2082
} ) ,
2054
2083
run_args: Box :: new( get_default_run_args( ) )
@@ -2063,7 +2092,7 @@ mod test {
2063
2092
command: Some ( Command :: Run {
2064
2093
execution_args: Box :: new( ExecutionArgs {
2065
2094
tasks: vec![ "build" . to_string( ) ] ,
2066
- remote_only: true ,
2095
+ remote_only: Some ( Some ( true ) ) ,
2067
2096
..get_default_execution_args( )
2068
2097
} ) ,
2069
2098
run_args: Box :: new( get_default_run_args( ) )
@@ -2078,7 +2107,7 @@ mod test {
2078
2107
command: Some ( Command :: Run {
2079
2108
execution_args: Box :: new( ExecutionArgs {
2080
2109
tasks: vec![ "build" . to_string( ) ] ,
2081
- remote_only: true ,
2110
+ remote_only: Some ( Some ( true ) ) ,
2082
2111
..get_default_execution_args( )
2083
2112
} ) ,
2084
2113
run_args: Box :: new( get_default_run_args( ) )
@@ -2093,7 +2122,7 @@ mod test {
2093
2122
command: Some ( Command :: Run {
2094
2123
execution_args: Box :: new( ExecutionArgs {
2095
2124
tasks: vec![ "build" . to_string( ) ] ,
2096
- remote_only: false ,
2125
+ remote_only: Some ( Some ( false ) ) ,
2097
2126
..get_default_execution_args( )
2098
2127
} ) ,
2099
2128
run_args: Box :: new( get_default_run_args( ) )
0 commit comments