Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var github = require('octonode');
- const readline = require('readline');
- const rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout
- });
- function main() {
- enter_username();
- }
- if (require.main === module) {
- main();
- }
- function enter_username() {
- rl.question('username: ', (username) => {
- enter_password(username);
- });
- }
- function enter_password(username) {
- rl.question('password: ', (password) => {
- rl.close();
- authenticate(username, password);
- });
- }
- function authenticate(username, password) {
- var client = github.client({
- username: username,
- password: password
- });
- client.get('/user', {}, function (err, status, body, headers) {
- print_repositories(client);
- });
- }
- function print_repositories(client) {
- console.log("List of repositories:");
- var ghme = client.me();
- ghme.repos(function(err, data, headers) {
- for (var i = 0; i < data.length; i++) {
- console.log(data[i].name + ": " + data[i].description);
- }
- });
- }
Add Comment
Please, Sign In to add comment