Skip to content

Commit

Permalink
feat(): show help if command provided is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Jiang committed Nov 20, 2018
1 parent 0981749 commit ed71d9d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions bin/afs-add
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const { argv } = program
})
}, onadd)
.help('h')
.recommendCommands()
.strict()

async function onadd(argv) {
const [ ...paths ] = argv.pathspec
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-commit
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const { argv } = program
})
}, oncommit)
.help('h')
.recommendCommands()
.strict()

async function oncommit(argv) {
const {
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-create
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const { argv } = program
})
}, oncreate)
.help('h')
.recommendCommands()
.strict()

async function oncreate(argv) {
let { owner } = argv
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const { argv } = program
})
}, ondeploy)
.help('h')
.recommendCommands()
.strict()

async function ondeploy(argv) {
const {
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-destroy
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const { argv } = program
})
}, ondestroy)
.help('h')
.recommendCommands()
.strict()

async function ondestroy(argv) {
const {
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-history
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const { argv } = program
})
}, onhistory)
.help('h')
.recommendCommands()
.strict()

async function onhistory(argv) {
let { did } = argv
Expand Down
7 changes: 2 additions & 5 deletions bin/afs-metadata
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const { argv } = program
describe: 'Print full metadata after write'
})
}, onmetadatawritekey)
.help('h')
.command('read-key <did> <key>', "Read a key's value from AFS metadata", (_) => {
_
.positional('did', {
Expand All @@ -48,7 +47,6 @@ const { argv } = program
describe: 'The key to write'
})
}, onmetadatareadkey)
.help('h')
.command('delete-key <did> <key>', "Delete a key-value pair from the AFS' metadata file", (_) => {
_
.positional('did', {
Expand All @@ -65,23 +63,20 @@ const { argv } = program
describe: 'Print full metadata after delete'
})
}, onmetadatadeletekey)
.help('h')
.command('clear <did>', 'Clears all metadata from an AFS', (_) => {
_
.positional('did', {
type: 'string',
describe: 'An AFS ARA decentralized identity (did) URI'
})
}, onmetadataclear)
.help('h')
.command('print <did>', 'Prints current metadata for an AFS', (_) => {
_
.positional('did', {
type: 'string',
describe: 'An AFS ARA decentralized identity (did) URI'
})
}, onmetadataprint)
.help('h')
.command('write-file <did> <filepath>', 'Writes contents of entire file to metadata', (_) => {
_
.positional('did', {
Expand All @@ -90,6 +85,8 @@ const { argv } = program
})
}, onmetadatawritefile)
.help('h')
.recommendCommands()
.strict()

async function onmetadatawritekey(argv) {
const {
Expand Down
5 changes: 2 additions & 3 deletions bin/afs-ownership
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const { argv } = program
describe: 'An AFS ARA decentralized identity (did) URI'
})
}, onrequestownership)
.help('h')
.command('revoke <requesterDid> <contentDid>', 'Revokes a previous request for ownership of an AFS', (_) => {
_
.positional('requester-did', {
Expand All @@ -44,7 +43,6 @@ const { argv } = program
describe: 'An AFS ARA decentralized identity (did) URI'
})
}, onrevokerequest)
.help('h')
.command('approve <contentDid> <newOwnerDid>', 'Approves an ownership transfer', (_) => {
_
.positional('content-did', {
Expand All @@ -56,7 +54,6 @@ const { argv } = program
describe: 'DID to transfer ownership to'
})
}, onapprovetransfer)
.help('h')
.command('claim <contentDid>', "Claim an AFS' identity", (_) => {
_
.positional('content-did', {
Expand All @@ -65,6 +62,8 @@ const { argv } = program
})
}, onclaimownership)
.help('h')
.recommendCommands()
.strict()

async function onrequestownership(argv) {
const {
Expand Down
3 changes: 2 additions & 1 deletion bin/afs-price
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const { argv } = program
describe: 'Force set price operation',
})
}, onsetprice)
.help('h')
.command('get <did>', 'Return the price for a given AFS', (_) => {
_
.positional('did', {
Expand All @@ -45,6 +44,8 @@ const { argv } = program
})
}, ongetprice)
.help('h')
.recommendCommands()
.strict()

async function onsetprice(argv) {
const { did } = argv
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-remove
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const { argv } = program
})
}, onremove)
.help('h')
.recommendCommands()
.strict()

async function onremove(argv) {
const [ ...paths ] = argv.pathspec
Expand Down
2 changes: 2 additions & 0 deletions bin/afs-unarchive
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const { argv } = program
})
}, onunarchive)
.help('h')
.recommendCommands()
.strict()

async function onunarchive(argv) {
const {
Expand Down

0 comments on commit ed71d9d

Please sign in to comment.