Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
feat(help): add help flag
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmeinke committed Sep 22, 2018
1 parent c722879 commit d65cc12
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
5 changes: 2 additions & 3 deletions commands/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ module.exports = args => {
}
])
.then(({ user }) => {
console.log(
`Yay, it's ${chalk.bold.green(user)}! My favourie team member.`
)
console.log(`
Yay, it's ${chalk.bold.green(user)}! My favourie team member.`)
})
}
6 changes: 6 additions & 0 deletions commands/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = () => {
console.log(`Usage: s8 <command>
Where <command> is one of:
hello`)
}
3 changes: 3 additions & 0 deletions commands/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { version } = require('../package.json')

module.exports = () => console.log(version)
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

const chalk = require('chalk')
const helloCmd = require('./commands/hello')
const package = require('./package.json');
const helpCmd = require('./commands/help')
const versionCmd = require('./commands/version')

const args = process.argv.splice(2)

switch(args[0]) {
case '--help':
case '-h':
case undefined:
helpCmd()
break

case '--version':
case '-v':
console.log(package.version)
versionCmd()
break

case 'hello':
Expand Down

0 comments on commit d65cc12

Please sign in to comment.