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

Commit

Permalink
feat(hello): create hello command
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmeinke committed Sep 22, 2018
1 parent f66d84c commit 169de31
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
32 changes: 32 additions & 0 deletions commands/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const chalk = require('chalk')
const inquirer = require('inquirer')

module.exports = args => {
inquirer
.prompt([
{
type: 'list',
name: 'user',
message: 'Who the heck are you?',
choices: [
'Aryeh',
'Colin',
'Ed',
'Fran',
'Ildar',
'John',
'Laszlo',
'Leo',
'Mario',
'Mathew',
'Monika',
'Steve',
]
}
])
.then(({ user }) => {
console.log(
`Yay, it's ${chalk.bold.green(user)}! My favourie team member.`
)
})
}
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/usr/bin/env node

const chalk = require('chalk')
const helloCmd = require('./commands/hello')

const args = process.argv.splice(2)

console.log(
`The ${chalk.bold(args.join(' '))} command is not defined... yet!`
)
switch(args[0]) {
case 'hello':
helloCmd(args)
break

default:
console.log(
`The ${chalk.bold.red(args.join(' '))} command is not defined... yet!`
)
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
}
},
"dependencies": {
"chalk": "^2.4.1"
"chalk": "^2.4.1",
"inquirer": "^6.2.0"
},
"description": "A pointless CLI",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3070,7 +3070,7 @@ [email protected]:
strip-ansi "^3.0.0"
through "^2.3.6"

inquirer@^6.0.0:
inquirer@^6.0.0, inquirer@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.2.0.tgz#51adcd776f661369dc1e894859c2560a224abdd8"
dependencies:
Expand Down

0 comments on commit 169de31

Please sign in to comment.