@@ -81,25 +81,25 @@ pub struct TaskConfig {
81
81
inputs : Option < serde_json:: Value > ,
82
82
}
83
83
84
- #[ derive( Debug , Default , Clone , Copy , PartialEq , Eq , Deserialize , Serialize ) ]
85
- #[ serde( rename_all = "snake_case" ) ] // TODO: which case?
86
- pub enum TaskRunMode {
84
+ #[ derive( Debug , Default , Clone , Copy , PartialEq , Eq , Deserialize , Serialize , clap :: ValueEnum ) ]
85
+ #[ serde( rename_all = "snake_case" ) ]
86
+ pub enum RunMode {
87
87
#[ default]
88
- /// Run only the specified task
88
+ /// Run only the specified task without dependencies
89
89
Single ,
90
- /// Run the specified task and all tasks after it
91
- WithAfter ,
92
- /// Run the specified task and all tasks before it
93
- WithBefore ,
94
- /// Run the specified task and all tasks before and after it (full dependency graph )
95
- WithBeforeAndAfter ,
90
+ /// Run the specified task and all tasks that depend on it (downstream tasks)
91
+ After ,
92
+ /// Run all dependency tasks first, then the specified task (upstream tasks)
93
+ Before ,
94
+ /// Run the complete dependency graph (upstream and downstream tasks )
95
+ All ,
96
96
}
97
97
98
98
#[ derive( Deserialize , Serialize ) ]
99
99
pub struct Config {
100
100
pub tasks : Vec < TaskConfig > ,
101
101
pub roots : Vec < String > ,
102
- pub run_mode : TaskRunMode ,
102
+ pub run_mode : RunMode ,
103
103
}
104
104
105
105
#[ derive( Serialize ) ]
@@ -401,7 +401,7 @@ struct Tasks {
401
401
tasks_order : Vec < NodeIndex > ,
402
402
notify_finished : Arc < Notify > ,
403
403
notify_ui : Arc < Notify > ,
404
- run_mode : TaskRunMode ,
404
+ run_mode : RunMode ,
405
405
}
406
406
407
407
impl Tasks {
@@ -504,11 +504,11 @@ impl Tasks {
504
504
505
505
// Find nodes to include based on run_mode
506
506
match self . run_mode {
507
- TaskRunMode :: Single => {
507
+ RunMode :: Single => {
508
508
// Only include the root nodes themselves
509
509
visited = self . roots . iter ( ) . cloned ( ) . collect ( ) ;
510
510
}
511
- TaskRunMode :: WithAfter => {
511
+ RunMode :: After => {
512
512
// Include root nodes and all tasks that come after (successor nodes)
513
513
while let Some ( node) = to_visit. pop ( ) {
514
514
if visited. insert ( node) {
@@ -522,7 +522,7 @@ impl Tasks {
522
522
}
523
523
}
524
524
}
525
- TaskRunMode :: WithBefore => {
525
+ RunMode :: Before => {
526
526
// Include root nodes and all tasks that come before (predecessor nodes)
527
527
while let Some ( node) = to_visit. pop ( ) {
528
528
if visited. insert ( node) {
@@ -536,7 +536,7 @@ impl Tasks {
536
536
}
537
537
}
538
538
}
539
- TaskRunMode :: WithBeforeAndAfter => {
539
+ RunMode :: All => {
540
540
// Include the complete connected subgraph (all dependencies in both directions)
541
541
while let Some ( node) = to_visit. pop ( ) {
542
542
if visited. insert ( node) {
@@ -1098,7 +1098,7 @@ mod test {
1098
1098
assert_matches ! (
1099
1099
Config :: try_from( json!( {
1100
1100
"roots" : [ ] ,
1101
- "run_mode" : "with_before_and_after " ,
1101
+ "run_mode" : "all " ,
1102
1102
"tasks" : [ {
1103
1103
"name" : task. to_string( )
1104
1104
} ]
@@ -1119,7 +1119,7 @@ mod test {
1119
1119
assert_matches ! (
1120
1120
Config :: try_from( serde_json:: json!( {
1121
1121
"roots" : [ ] ,
1122
- "run_mode" : "with_before_and_after " ,
1122
+ "run_mode" : "all " ,
1123
1123
"tasks" : [ {
1124
1124
"name" : task. to_string( )
1125
1125
} ]
@@ -1150,7 +1150,7 @@ mod test {
1150
1150
let tasks = Tasks :: new (
1151
1151
Config :: try_from ( json ! ( {
1152
1152
"roots" : [ "myapp:task_1" , "myapp:task_4" ] ,
1153
- "run_mode" : "with_before_and_after " ,
1153
+ "run_mode" : "all " ,
1154
1154
"tasks" : [
1155
1155
{
1156
1156
"name" : "myapp:task_1" ,
@@ -1195,7 +1195,7 @@ mod test {
1195
1195
let result = Tasks :: new (
1196
1196
Config :: try_from ( json ! ( {
1197
1197
"roots" : [ "myapp:task_1" ] ,
1198
- "run_mode" : "with_before_and_after " ,
1198
+ "run_mode" : "all " ,
1199
1199
"tasks" : [
1200
1200
{
1201
1201
"name" : "myapp:task_1" ,
@@ -1243,7 +1243,7 @@ mod test {
1243
1243
Tasks :: new (
1244
1244
Config :: try_from ( json ! ( {
1245
1245
"roots" : [ root] ,
1246
- "run_mode" : "with_before_and_after " ,
1246
+ "run_mode" : "all " ,
1247
1247
"tasks" : [
1248
1248
{
1249
1249
"name" : "myapp:task_1" ,
@@ -1286,7 +1286,7 @@ mod test {
1286
1286
let tasks = Tasks :: new (
1287
1287
Config :: try_from ( json ! ( {
1288
1288
"roots" : [ "myapp:task_1" ] ,
1289
- "run_mode" : "with_before_and_after " ,
1289
+ "run_mode" : "all " ,
1290
1290
"tasks" : [
1291
1291
{
1292
1292
"name" : "myapp:task_1" ,
@@ -1327,7 +1327,7 @@ mod test {
1327
1327
let result = Tasks :: new (
1328
1328
Config :: try_from ( json ! ( {
1329
1329
"roots" : [ "myapp:task_1" ] ,
1330
- "run_mode" : "with_before_and_after " ,
1330
+ "run_mode" : "all " ,
1331
1331
"tasks" : [
1332
1332
{
1333
1333
"name" : "myapp:task_1" ,
@@ -1396,7 +1396,7 @@ mod test {
1396
1396
let tasks = Tasks :: new (
1397
1397
Config :: try_from ( json ! ( {
1398
1398
"roots" : [ "myapp:task_1" ] ,
1399
- "run_mode" : "with_before_and_after " ,
1399
+ "run_mode" : "all " ,
1400
1400
"tasks" : [
1401
1401
{
1402
1402
"name" : "myapp:task_1" ,
@@ -1441,7 +1441,7 @@ mod test {
1441
1441
let tasks = Tasks :: new (
1442
1442
Config :: try_from ( json ! ( {
1443
1443
"roots" : [ "myapp:task_1" ] ,
1444
- "run_mode" : "with_before_and_after " ,
1444
+ "run_mode" : "all " ,
1445
1445
"tasks" : [
1446
1446
{
1447
1447
"name" : "myapp:task_1" ,
@@ -1486,7 +1486,7 @@ mod test {
1486
1486
let tasks = Tasks :: new (
1487
1487
Config :: try_from ( json ! ( {
1488
1488
"roots" : [ "myapp:task_1" ] ,
1489
- "run_mode" : "with_before_and_after " ,
1489
+ "run_mode" : "all " ,
1490
1490
"tasks" : [
1491
1491
{
1492
1492
"name" : "myapp:task_1" ,
@@ -1533,7 +1533,7 @@ mod test {
1533
1533
let tasks = Tasks :: new (
1534
1534
Config :: try_from ( json ! ( {
1535
1535
"roots" : [ "myapp:task_3" ] ,
1536
- "run_mode" : "with_before_and_after " ,
1536
+ "run_mode" : "all " ,
1537
1537
"tasks" : [
1538
1538
{
1539
1539
"name" : "myapp:task_1" ,
@@ -1579,7 +1579,7 @@ mod test {
1579
1579
let tasks = Tasks :: new (
1580
1580
Config :: try_from ( json ! ( {
1581
1581
"roots" : [ "myapp:task_2" ] ,
1582
- "run_mode" : "with_before_and_after " ,
1582
+ "run_mode" : "all " ,
1583
1583
"tasks" : [
1584
1584
{
1585
1585
"name" : "myapp:task_1" ,
@@ -1623,7 +1623,7 @@ mod test {
1623
1623
let tasks = Tasks :: new (
1624
1624
Config :: try_from ( json ! ( {
1625
1625
"roots" : [ "myapp:task_2" ] ,
1626
- "run_mode" : "with_before_and_after " ,
1626
+ "run_mode" : "all " ,
1627
1627
"tasks" : [
1628
1628
{
1629
1629
"name" : "myapp:task_1" ,
@@ -1679,7 +1679,7 @@ echo '{"key": "value3"}' > $DEVENV_TASK_OUTPUT_FILE
1679
1679
let tasks = Tasks :: new (
1680
1680
Config :: try_from ( json ! ( {
1681
1681
"roots" : [ "myapp:task_3" ] ,
1682
- "run_mode" : "with_before_and_after " ,
1682
+ "run_mode" : "all " ,
1683
1683
"tasks" : [
1684
1684
{
1685
1685
"name" : "myapp:task_1" ,
1738
1738
let tasks = Tasks :: new (
1739
1739
Config :: try_from ( json ! ( {
1740
1740
"roots" : [ "myapp:task_1" , "myapp:task_2" ] ,
1741
- "run_mode" : "with_before_and_after " ,
1741
+ "run_mode" : "all " ,
1742
1742
"tasks" : [
1743
1743
{
1744
1744
"name" : "myapp:task_1" ,
0 commit comments