Skip to content

Commit

Permalink
Added missing logic to disable help.
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Apr 30, 2020
1 parent 8bfa21c commit 130de1b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@author.io/shell",
"version": "1.3.11",
"version": "1.3.12",
"description": "A micro-framework for creating CLI-like experiences. This supports Node.js and browsers.",
"main": "src/index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export default class Base {
#name = 'Unknown'
#middleware = new Middleware()
#hasCustomDefaultHandler = false
#defaultHandler = function () {
#defaultHandler = function (meta) {
if (this.parent !== null && this.parent.hasCustomDefaultHandler) {
return this.parent.defaultHandler(...arguments)
} else if (this.shell.hasCustomDefaultHandler) {
return this.shell.defaultHandler(...arguments)
}

console.log(this.help)
if (this.#autohelp) {
console.log(this.help)
}
}

constructor(cfg = {}) {
Expand Down
6 changes: 5 additions & 1 deletion test/unit/01-sanity/01-sanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ test('Subcommand Config', t => {
// const shell = new Shell({
// name: 'test',
// version: '1.0.0',
// defaultHandler: () => console.log('yo'),
// disableHelp: true,
// // defaultHandler: () => console.log('yo'),
// commands: [
// {
// name: 'account',
Expand All @@ -144,6 +145,9 @@ test('Subcommand Config', t => {
// name: 'create',
// description: 'Create a user account.',
// arguments: '<email>',
// help () {
// return 'overridden help'
// },
// flags: {
// name: {
// alias: 'n',
Expand Down

0 comments on commit 130de1b

Please sign in to comment.