Guest User

Untitled

a guest
May 1st, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. var github = require('octonode');
  2. const readline = require('readline');
  3.  
  4. const rl = readline.createInterface({
  5. input: process.stdin,
  6. output: process.stdout
  7. });
  8.  
  9. function main() {
  10. enter_username();
  11. }
  12.  
  13. if (require.main === module) {
  14. main();
  15. }
  16.  
  17. function enter_username() {
  18. rl.question('username: ', (username) => {
  19. enter_password(username);
  20. });
  21. }
  22.  
  23. function enter_password(username) {
  24. rl.question('password: ', (password) => {
  25. rl.close();
  26. authenticate(username, password);
  27. });
  28. }
  29.  
  30. function authenticate(username, password) {
  31. var client = github.client({
  32. username: username,
  33. password: password
  34. });
  35.  
  36. client.get('/user', {}, function (err, status, body, headers) {
  37. print_repositories(client);
  38. });
  39. }
  40.  
  41. function print_repositories(client) {
  42. console.log("List of repositories:");
  43.  
  44. var ghme = client.me();
  45. ghme.repos(function(err, data, headers) {
  46. for (var i = 0; i < data.length; i++) {
  47. console.log(data[i].name + ": " + data[i].description);
  48. }
  49. });
  50. }
Add Comment
Please, Sign In to add comment