normal-usage.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var colors = require('../lib/index');
  2. console.log('First some yellow text'.yellow);
  3. console.log('Underline that text'.yellow.underline);
  4. console.log('Make it bold and red'.red.bold);
  5. console.log(('Double Raindows All Day Long').rainbow);
  6. console.log('Drop the bass'.trap);
  7. console.log('DROP THE RAINBOW BASS'.trap.rainbow);
  8. // styles not widely supported
  9. console.log('Chains are also cool.'.bold.italic.underline.red);
  10. // styles not widely supported
  11. console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
  12. + ' styles! '.yellow.bold);
  13. console.log('Zebras are so fun!'.zebra);
  14. //
  15. // Remark: .strikethrough may not work with Mac OS Terminal App
  16. //
  17. console.log('This is ' + 'not'.strikethrough + ' fun.');
  18. console.log('Background color attack!'.black.bgWhite);
  19. console.log('Use random styles on everything!'.random);
  20. console.log('America, Heck Yeah!'.america);
  21. console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);
  22. console.log('Setting themes is useful');
  23. //
  24. // Custom themes
  25. //
  26. console.log('Generic logging theme as JSON'.green.bold.underline);
  27. // Load theme with JSON literal
  28. colors.setTheme({
  29. silly: 'rainbow',
  30. input: 'grey',
  31. verbose: 'cyan',
  32. prompt: 'grey',
  33. info: 'green',
  34. data: 'grey',
  35. help: 'cyan',
  36. warn: 'yellow',
  37. debug: 'blue',
  38. error: 'red',
  39. });
  40. // outputs red text
  41. console.log('this is an error'.error);
  42. // outputs yellow text
  43. console.log('this is a warning'.warn);
  44. // outputs grey text
  45. console.log('this is an input'.input);
  46. console.log('Generic logging theme as file'.green.bold.underline);
  47. // Load a theme from file
  48. try {
  49. colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
  50. } catch (err) {
  51. console.log(err);
  52. }
  53. // outputs red text
  54. console.log('this is an error'.error);
  55. // outputs yellow text
  56. console.log('this is a warning'.warn);
  57. // outputs grey text
  58. console.log('this is an input'.input);
  59. // console.log("Don't summon".zalgo)