Skip to content

Commit

Permalink
feat(utils): add basic CLI spec for database importer
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed May 13, 2019
1 parent da76883 commit 2ebd8b2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
22 changes: 22 additions & 0 deletions lib/import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const program = require( 'commander' )

const main = async () => {
program
.version( '0.0.1' )
.arguments( '<input>' )
.option( '-s --shabad-id <column>', 'Shabad ID column name', 'ShabadID' )
.option( '-t, --translation <column>', 'column name of a translation', ( val, prev ) => [ ...prev, val ], [] )
.option( '-p, --page <column>', 'Page number column name', 'PageNo' )
.option( '-l, --line <column>', 'Line number column name', 'LineNo' )
.option( '-S, --sttm <column>', 'STTM 2 ID column name', 'ID' )
.option( '-g, --gurmukhi <column>', 'Gurmukhi column name', 'Gurmukhi' )
.parse( process.argv )

const [ filename ] = program.args

if ( !filename ) program.outputHelp()
}

main()
.then( () => process.exit( 0 ) )
.catch( e => console.error( e ) && process.exit( 1 ) )
48 changes: 14 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "4.0.15",
"description": "The open gurbani database containing an evolving set of corrections. Used in Shabad OS software.",
"scripts": {
"import": "node lib/import.js",
"benchmark": "node lib/benchmark.js",
"build-sqlite": "node lib/build-sqlite.js",
"build-json": "node lib/build-json.js",
Expand Down Expand Up @@ -46,6 +47,7 @@
"dependencies": {
"anyid": "^1.0.5",
"colors": "^1.3.2",
"commander": "^2.20.0",
"fast.js": "^0.1.1",
"freshy": "^1.0.4",
"gurmukhi-utils": "^2.0.3",
Expand Down

0 comments on commit 2ebd8b2

Please sign in to comment.