@@ -74,12 +74,32 @@ const command = new Command({
7474 type : Array ,
7575 default : [ ] ,
7676 } )
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+ } )
7797 . example ( 'codefresh get build ID' , 'Get build ID' )
7898 . example ( 'codefresh get builds' , 'Get all builds' )
7999 . example ( 'codefresh get builds --pipeline-id ID' , 'Get all builds that are executions of pipeline "ID"' )
80100 . 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' ) ;
83103 } ,
84104 handler : async ( argv ) => {
85105 const workflowIds = argv . id ;
@@ -91,9 +111,12 @@ const command = new Command({
91111 branch : branchName ,
92112 commitId : revision ,
93113 'pipeline-trigger-id' : pipelineTriggerId ,
114+ from,
115+ to,
94116 } = argv ;
95117 const pipelineNames = ! _ . isArray ( argv [ 'pipeline-name' ] ) ? [ ( argv [ 'pipeline-name' ] ) ] : argv [ 'pipeline-name' ] ;
96118 const pipelineIds = ! _ . isArray ( argv [ 'pipeline-id' ] ) ? [ ( argv [ 'pipeline-id' ] ) ] : argv [ 'pipeline-id' ] ;
119+
97120 const requestOptions = {
98121 limit,
99122 page,
@@ -102,6 +125,9 @@ const command = new Command({
102125 branchName,
103126 revision,
104127 pipelineTriggerId,
128+ paginationReset : page === 1 ,
129+ startDate : from ,
130+ endDate : to ,
105131 } ;
106132
107133 let workflows = [ ] ;
0 commit comments