1
1
// code here to write the tool for csv tool show
2
2
import { Command , flags } from '@oclif/command'
3
+ import * as chalk from 'chalk'
3
4
4
5
import Logger from '../utilities/logger'
5
6
import Utilities from '../utilities/utilities'
@@ -11,7 +12,7 @@ export default class View extends Command {
11
12
static flags = {
12
13
help : flags . help ( { char : 'h' } ) ,
13
14
file : flags . string ( { char : 'f' , description : 'formatted file to be shown' } ) ,
14
- num : flags . string ( { char : 'n' , description : ' rows to show' } )
15
+ num : flags . string ( { char : 'n' , description : `no. of rows to show, default: ${ View . DEFAULT_COUNT } ` } )
15
16
}
16
17
17
18
static args = [ { name : 'file' } ]
@@ -74,13 +75,19 @@ export default class View extends Command {
74
75
}
75
76
}
76
77
78
+ // -1 need to be done to exclude header
79
+ // ${chalk.yellow('Avro Schema')
80
+ Logger . info ( this , `Total ${ chalk . greenBright ( rows . length - 2 ) } records in file.` )
81
+ Logger . info ( this , `showing top ${ chalk . yellow ( recordsToShow - 1 ) } records.` )
82
+
77
83
this . printRow ( rows [ 0 ] . split ( ',' ) , widthArray , '+' , true )
78
84
for ( let i = 0 ; i < recordsToShow ; i ++ ) {
79
85
let row = rows [ i ]
80
86
this . printRow ( row . split ( ',' ) , widthArray , '|' , false )
81
87
this . printRow ( row . split ( ',' ) , widthArray , '+' , true )
82
88
}
83
- this . log ( `showing top ${ recordsToShow } rows.` )
89
+
90
+ Logger . success ( this , 'done.\n' )
84
91
}
85
92
86
93
private printRow ( row : any , widthArray : any , seperator : any , isLineSeparator : any ) {
0 commit comments