-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Switch to yargs. #189
Switch to yargs. #189
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,7 @@ function deleteSink (name, callback) { | |
|
||
// The command-line program | ||
var cli = require('yargs'); | ||
var utils = require('../utils'); | ||
|
||
var program = module.exports = { | ||
createSink: createSink, | ||
|
@@ -181,24 +182,24 @@ cli | |
description: 'The type of destination.' | ||
} | ||
}, function (options) { | ||
program.createSink(options, console.log); | ||
program.createSink(utils.pick(options, ['name', 'destination', 'filter', 'type']), utils.makeHandler(false)); | ||
}) | ||
.command('get <name>', 'Get the metadata for the specified sink.', {}, function (options) { | ||
program.getSinkMetadata(options.name, console.log); | ||
program.getSinkMetadata(options.name, utils.makeHandler()); | ||
}) | ||
.command('list', 'List all sinks in the authenticated project.', {}, function () { | ||
program.listSinks(console.log); | ||
program.listSinks(utils.makeHandler(true, 'id')); | ||
}) | ||
.command('update <name> <metadata>', 'Update the metadata for the specified sink.', {}, function (options) { | ||
try { | ||
options.metadata = JSON.parse(options.metadata); | ||
} catch (err) { | ||
return console.error('"metadata" must be a valid JSON string!'); | ||
} | ||
program.updateSink(options, console.log); | ||
program.updateSink(utils.pick(options, ['name', 'metadata']), utils.makeHandler(false)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another option (for later use): instead of whitelisting the yargs options we want, we blacklist the ones we don't. (IIRC we briefly discussed this yesterday but didn't rule it out.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will address in another PR. |
||
}) | ||
.command('delete <name>', 'Delete the specified sink.', {}, function (options) { | ||
program.deleteSink(options.name, console.log); | ||
program.deleteSink(options.name, utils.makeHandler(false)); | ||
}) | ||
.example('node $0 create my-sink my-bucket --type bucket', 'Create a new sink named "my-sink" that exports logs to a Cloud Storage bucket.') | ||
.example('node $0 create my-sink my-dataset --type dataset', 'Create a new sink named "my-sink" that exports logs to a BigQuery dataset.') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not terribly worried about this change (because it needs to be done anyway), but this wasn't technically a
yargs
change. 😛