File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 11<h1 align =" center " >table-printer-cli</h1 >
22<h3 align =" center " >📟🍭Printing Pretty Tables on your terminal</h3 >
33<p align =" center " >
4- <a href =" https://travis-ci.com/ayonious/table-printer-cli " >
5- <img alt="Build Status" src="https://travis-ci.com/ayonious/table-printer-cli.svg?branch=master">
6- </a >
4+ <a href =" https://dl.circleci.com/status-badge/redirect/gh/ayonious/table-printer-cli/tree/master " ><img src =" https://dl.circleci.com/status-badge/img/gh/ayonious/table-printer-cli/tree/master.svg?style=svg " ></a >
75 <a href =" https://codecov.io/gh/ayonious/table-printer-cli " >
86 <img alt="codecov" src="https://codecov.io/gh/ayonious/table-printer-cli/branch/master/graph/badge.svg">
97 </a >
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2- import { program } from 'commander' ;
2+ import { Command } from 'commander' ;
33import * as fs from 'fs' ;
44
55import printTableFromInp from './src/service' ;
66
7+ const program = new Command ( ) ;
8+
79program
810 . option ( '-i, --input <value>' , 'input string' )
911 . option ( '-s, --stdin' , 'read input from stdin' )
1012 . parse ( process . argv ) ;
1113
12- if ( program . input ) {
13- console . log ( 'program.input' , program . input ) ;
14- printTableFromInp ( program . input ) ;
15- } else if ( program . stdin ) {
14+ const options = program . opts ( ) ;
15+
16+ if ( options . input ) {
17+ console . log ( 'program.input' , options . input ) ;
18+ printTableFromInp ( options . input ) ;
19+ } else if ( options . stdin ) {
1620 printTableFromInp ( fs . readFileSync ( 0 ) . toString ( ) ) ;
1721} else {
1822 console . log ( 'Error: Cant detect input option' ) ;
You can’t perform that action at this time.
0 commit comments