@@ -74,12 +74,32 @@ const command = new Command({
74
74
type : Array ,
75
75
default : [ ] ,
76
76
} )
77
+ . option ( 'from' , {
78
+ describe : 'Date in format: YYYY-MM-DD. Show builds from the provided date' ,
79
+ type : String ,
80
+ } )
81
+ . option ( 'to' , {
82
+ describe : 'Date in format: YYYY-MM-DD. Show builds up to provided date' ,
83
+ type : String ,
84
+ } )
85
+ . check ( ( argv ) => {
86
+ const { from, to } = argv ;
87
+
88
+ const dateRegex = / ^ \d { 4 } - \d { 1 , 2 } - \d { 1 , 2 } $ / ;
89
+ if ( from && ! dateRegex . test ( from ) ) {
90
+ throw new Error ( '--from option should take a date in format: YYYY-MM-DD. Example: --from 2020-12-31' ) ;
91
+ }
92
+ if ( to && ! dateRegex . test ( to ) ) {
93
+ throw new Error ( '--to option should take a date in format: YYYY-MM-DD. Example: --to 2020-12-31' ) ;
94
+ }
95
+ return true ;
96
+ } )
77
97
. example ( 'codefresh get build ID' , 'Get build ID' )
78
98
. example ( 'codefresh get builds' , 'Get all builds' )
79
99
. example ( 'codefresh get builds --pipeline-id ID' , 'Get all builds that are executions of pipeline "ID"' )
80
100
. example ( 'codefresh get builds --pipeline-name NAME' , 'Get all builds that are executions of pipelines that are named "NAME"' )
81
- . example ( 'codefresh get builds --status=error' , 'Get all builds that their status is error' ) ;
82
-
101
+ . example ( 'codefresh get builds --status=error' , 'Get all builds that their status is error' )
102
+ . example ( 'codefresh get builds --from=2020-01-01 --to=2020-02-01' , 'Get all builds within given date range' ) ;
83
103
} ,
84
104
handler : async ( argv ) => {
85
105
const workflowIds = argv . id ;
@@ -91,9 +111,12 @@ const command = new Command({
91
111
branch : branchName ,
92
112
commitId : revision ,
93
113
'pipeline-trigger-id' : pipelineTriggerId ,
114
+ from,
115
+ to,
94
116
} = argv ;
95
117
const pipelineNames = ! _ . isArray ( argv [ 'pipeline-name' ] ) ? [ ( argv [ 'pipeline-name' ] ) ] : argv [ 'pipeline-name' ] ;
96
118
const pipelineIds = ! _ . isArray ( argv [ 'pipeline-id' ] ) ? [ ( argv [ 'pipeline-id' ] ) ] : argv [ 'pipeline-id' ] ;
119
+
97
120
const requestOptions = {
98
121
limit,
99
122
page,
@@ -102,6 +125,9 @@ const command = new Command({
102
125
branchName,
103
126
revision,
104
127
pipelineTriggerId,
128
+ paginationReset : page === 1 ,
129
+ startDate : from ,
130
+ endDate : to ,
105
131
} ;
106
132
107
133
let workflows = [ ] ;
0 commit comments