Skip to content

Commit ac98183

Browse files
committed
[cdt-98] - some fixes
Signed-off-by: ashish <[email protected]>
1 parent 5fe0cea commit ac98183

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/commands/view.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// code here to write the tool for csv tool show
22
import {Command, flags} from '@oclif/command'
3+
import * as chalk from 'chalk'
34

45
import Logger from '../utilities/logger'
56
import Utilities from '../utilities/utilities'
@@ -11,7 +12,7 @@ export default class View extends Command {
1112
static flags = {
1213
help: flags.help({char: 'h'}),
1314
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}`})
1516
}
1617

1718
static args = [{name: 'file'}]
@@ -74,13 +75,19 @@ export default class View extends Command {
7475
}
7576
}
7677

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+
7783
this.printRow(rows[0].split(','), widthArray, '+', true)
7884
for (let i = 0; i < recordsToShow; i++) {
7985
let row = rows[i]
8086
this.printRow(row.split(','), widthArray, '|', false)
8187
this.printRow(row.split(','), widthArray, '+', true)
8288
}
83-
this.log(`showing top ${recordsToShow} rows.`)
89+
90+
Logger.success(this, 'done.\n')
8491
}
8592

8693
private printRow(row: any, widthArray: any, seperator: any, isLineSeparator: any) {

test/commands/view.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('view', () => {
2424

2525
test
2626
.stdout()
27-
.command (['view', 'test/resources/csv/test_view.csv', '-n', '900'])
27+
.command(['view', 'test/resources/csv/test_view.csv', '-n', '900'])
2828
.it('check if the given number is greater than total lines', ctx => {
2929
expect(ctx.stdout).to.contain('|0 |3 |0 |32.0 |7.75 |0 |0 |')
3030
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Survived,Pclass,Sex,Age,Fare,Family_count,Cabin_ind
2+
0,3,0,22.0,7.25,1,0
3+
1,1,1,38.0,71.2833,1,1
4+
1,3,1,26.0,7.925,0,0
5+
1,1,1,35.0,53.1,1,1
6+
0,3,0,35.0,8.05,0,0
7+
0,3,0,29.69911764705882,8.4583,0,0
8+
0,1,0,54.0,51.8625,0,1
9+
0,3,0,2.0,21.075,4,0
10+
1,3,1,27.0,11.1333,2,0
11+
1,2,1,14.0,30.0708,1,0
12+
1,3,1,4.0,16.7,2,1
13+
1,1,1,58.0,26.55,0,1
14+
0,3,0,20.0,8.05,0,0

0 commit comments

Comments
 (0)