From the course: Building Your First CLI App in Node

Understand user prompts

From the course: Building Your First CLI App in Node

Start my 1-month free trial

Understand user prompts

- [Instructor] Now that we have the power to determine a Git repository has not yet been initialized and the user does, in fact, require a new Git repository for their project, let's create some prompts for the user to answer questions about the details of the Git repository they want to create. The very first thing we need to do is ask the user for their GitHub credentials. We'll use the Inquirer module to create these prompts. If you've used GitHub before, you know what this looks like. When you go to Push, it immediately asks for your username, and when that is entered it asks for your password right after. We'll have the same functionality in our app. Inquirer has methods included for a variety of different kinds of prompts. It's roughly similar to HTML form controls, in fact. To collect the user's GitHub username and password, we'll use Inquirer's input and password types. Right now this isn't actually connected to GitHub. All we are doing is setting up a form inside of the local app to receive the information. Before we implement these methods, we need somewhere to actually store them once we receive them. We're going to do that in the Inquirer file in your lib folder. The file path will be lib/inquirer.js. In our inquirer.js file, the first thing we need to do is import the modules we will be using, inquirer, minimist, and files. As in any Node.js code, we do this by requiring the modules and storing them in a variable or constant. This require here with files is again requiring files from our own directories for our app.

Contents