-
Notifications
You must be signed in to change notification settings - Fork 17
Extensively rework dynector to use yargs commands. #74
Conversation
The new usage is given in the README and as help. It uses yarg commands intead of named options. Specifically: dyn arecord <fqdn> <ip> make the given fqdn resolve to the given IP dyn cname <fqdn> <cname> make the given fqdn resolve to the given cname dyn delete <fqdn> remove the named node entirely dyn list <zone> list all records for the given zone dyn resolve <zone> resolve all records for the given zone; list the IPs Reworked the tests. Added `list`, which lists all records for the given zone, with types. Added `resolve`, which resolves all records for the given zones and emits a sorted list of all IPs in use. Added support for update-notifier. This will of course require a major-number version bump when landed.
.option('zone', | ||
{ | ||
alias: 'z', | ||
description: 'specify a zone', |
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.
These options should be marked global: true
to apply to all commands.
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.
Awesome! Exactly the kind of feedback I wanted from you!
describe: 'do not log informationally', | ||
type: 'boolean' | ||
}) | ||
.example('dynector arecord example.com 10.0.0.1') |
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.
Examples would look slightly better in the terminal if each one had a brief description, as second argument to each .example()
call.
.example('dynector delete oops.example.com', 'remove the entry for oops entirely') | ||
.example('dynector list example.com', 'list all records under example.com') | ||
.example('dynector resolve example.com', 'resolve IPs for all example.com records') | ||
.version() |
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.
With yargs 5, you can now do .recommendCommands()
to provide a suggestion if someone mistypes a command. 👍
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.
Looks good to me! This shouldn't change much in scripting, makes the UX better as well.
|
||
yargs.recommendCommands(); | ||
|
||
yargs.argv; |
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.
So accessing argv
here effectively starts the application?
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.
Correct. This is how yargs commands work.
😮 this is really cool! neat to see all the fancy new command functionality being put to good use. |
The new usage is given in the README and as help. It uses yargs commands intead of named options. Specifically:
dyn arecord <fqdn> <ip>
make the given fqdn resolve to the given IPdyn cname <fqdn> <cname>
make the given fqdn resolve to the given cnamedyn delete <fqdn>
remove the named node entirelydyn list <zone>
list all records for the given zonedyn resolve <zone>
resolve all records for the given zone; list the IPsReworked the tests.
Added
list
, which lists all records for the given zone, with types.Added
resolve
, which resolves all records for the given zones and emits a sorted list of all IPs in use.Added support for update-notifier.
This will of course require a major-number version bump when landed.