This repository has been archived by the owner on Jan 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luciano Nooijen
committed
Dec 6, 2018
1 parent
dce7612
commit 57b8dcd
Showing
5 changed files
with
377 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function addPost() { | ||
console.log('AddPost Working!'); | ||
} | ||
|
||
export default addPost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* tslint:disable: no-console */ | ||
|
||
import chalk from 'chalk'; | ||
import figlet from 'figlet'; | ||
import inquirer from 'inquirer'; | ||
|
||
import addPost from './add-post'; | ||
|
||
const prompt = inquirer.createPromptModule(); | ||
const choices = ['Add post']; | ||
const question = { | ||
choices, | ||
name: 'action', | ||
type: 'list', | ||
message: 'Please select the action you wish to perform', | ||
}; | ||
|
||
const intro = () => { | ||
console.clear(); | ||
console.log( | ||
chalk.yellow( | ||
figlet.textSync('NodeJS Blog', { horizontalLayout: 'full' }))); | ||
}; | ||
|
||
const promptHandler = async () => { | ||
const answer = await prompt([question]) as any; // Hack to avoid error... | ||
if (answer.action === 'Add post') { | ||
addPost(); | ||
} | ||
}; | ||
|
||
const cli = async () => { | ||
intro(); | ||
await promptHandler(); | ||
}; | ||
|
||
cli(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.