Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: add --exit-code & default to 0 #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bin/generate-schema
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var content = ''
var mode = 'json'
var quiet = false
var file = null
var exitCode = 0

// Setup CLI
cli.version(pkg.version)
Expand Down Expand Up @@ -44,12 +45,21 @@ cli.option('-c, --clickhouse', 'ClickHouse Table Schema output', function () {
mode = 'clickhouse'
})

cli.option('-x, --exit-code <code>', 'Process exit code to use for successful execution', function () {
exitCode = 0
})

cli.action(function (filename) {
file = filename
})

cli.parse(process.argv)

var options = cli.opts();
if (options.exitCode) {
exitCode = options.exitCode;
}

// Program

function evaluate (data) {
Expand Down Expand Up @@ -105,7 +115,7 @@ var stream = process.stdin
if (file) {
stream = fs.createReadStream(file)
stream.on('close', function () {
process.exit(1)
process.exit(exitCode)
})
}

Expand Down