Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
3.1 KiB

  1. # colors.js
  2. ## get color and style in your node.js console
  3. <img src="https://github.com/Marak/colors.js/raw/master/screenshots/colors.png"/>
  4. ## Installation
  5. npm install colors
  6. ## colors and styles!
  7. ### text colors
  8. - black
  9. - red
  10. - green
  11. - yellow
  12. - blue
  13. - magenta
  14. - cyan
  15. - white
  16. - gray
  17. - grey
  18. ### background colors
  19. - bgBlack
  20. - bgRed
  21. - bgGreen
  22. - bgYellow
  23. - bgBlue
  24. - bgMagenta
  25. - bgCyan
  26. - bgWhite
  27. ### styles
  28. - reset
  29. - bold
  30. - dim
  31. - italic
  32. - underline
  33. - inverse
  34. - hidden
  35. - strikethrough
  36. ### extras
  37. - rainbow
  38. - zebra
  39. - america
  40. - trap
  41. - random
  42. ## Usage
  43. By popular demand, `colors` now ships with two types of usages!
  44. The super nifty way
  45. ```js
  46. var colors = require('colors');
  47. console.log('hello'.green); // outputs green text
  48. console.log('i like cake and pies'.underline.red) // outputs red underlined text
  49. console.log('inverse the color'.inverse); // inverses the color
  50. console.log('OMG Rainbows!'.rainbow); // rainbow
  51. console.log('Run the trap'.trap); // Drops the bass
  52. ```
  53. or a slightly less nifty way which doesn't extend `String.prototype`
  54. ```js
  55. var colors = require('colors/safe');
  56. console.log(colors.green('hello')); // outputs green text
  57. console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text
  58. console.log(colors.inverse('inverse the color')); // inverses the color
  59. console.log(colors.rainbow('OMG Rainbows!')); // rainbow
  60. console.log(colors.trap('Run the trap')); // Drops the bass
  61. ```
  62. I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
  63. If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
  64. ## Disabling Colors
  65. To disable colors you can pass the following arguments in the command line to your application:
  66. ```bash
  67. node myapp.js --no-color
  68. ```
  69. ## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
  70. ```js
  71. var name = 'Marak';
  72. console.log(colors.green('Hello %s'), name);
  73. // outputs -> 'Hello Marak'
  74. ```
  75. ## Custom themes
  76. ### Using standard API
  77. ```js
  78. var colors = require('colors');
  79. colors.setTheme({
  80. silly: 'rainbow',
  81. input: 'grey',
  82. verbose: 'cyan',
  83. prompt: 'grey',
  84. info: 'green',
  85. data: 'grey',
  86. help: 'cyan',
  87. warn: 'yellow',
  88. debug: 'blue',
  89. error: 'red'
  90. });
  91. // outputs red text
  92. console.log("this is an error".error);
  93. // outputs yellow text
  94. console.log("this is a warning".warn);
  95. ```
  96. ### Using string safe API
  97. ```js
  98. var colors = require('colors/safe');
  99. // set single property
  100. var error = colors.red;
  101. error('this is red');
  102. // set theme
  103. colors.setTheme({
  104. silly: 'rainbow',
  105. input: 'grey',
  106. verbose: 'cyan',
  107. prompt: 'grey',
  108. info: 'green',
  109. data: 'grey',
  110. help: 'cyan',
  111. warn: 'yellow',
  112. debug: 'blue',
  113. error: 'red'
  114. });
  115. // outputs red text
  116. console.log(colors.error("this is an error"));
  117. // outputs yellow text
  118. console.log(colors.warn("this is a warning"));
  119. ```
  120. *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*