From the course: Building Your First CLI App in Node
Understand user prompts
From the course: Building Your First CLI App in Node
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.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Understand user prompts1m 46s
-
(Locked)
Create a prompt for user input2m 24s
-
(Locked)
Validate user input1m 53s
-
(Locked)
Store GitHub credentials for reuse3m 2s
-
(Locked)
Receive the GitHub token3m 39s
-
(Locked)
Authenticate with GitHub2m 29s
-
(Locked)
Register a new token3m 23s
-
(Locked)
Implement the GitHub token3m 31s
-
-
-
-