Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

README.md 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. # colors.js
  2. [![Build Status](https://travis-ci.org/Marak/colors.js.svg?branch=master)](https://travis-ci.org/Marak/colors.js)
  3. [![version](https://img.shields.io/npm/v/colors.svg)](https://www.npmjs.org/package/colors)
  4. [![dependencies](https://david-dm.org/Marak/colors.js.svg)](https://david-dm.org/Marak/colors.js)
  5. [![devDependencies](https://david-dm.org/Marak/colors.js/dev-status.svg)](https://david-dm.org/Marak/colors.js#info=devDependencies)
  6. Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. Please open Issues to provide feedback, and check the `develop` branch for the latest bleeding-edge updates.
  7. ## get color and style in your node.js console
  8. ![Demo](https://raw.githubusercontent.com/Marak/colors.js/master/screenshots/colors.png)
  9. ## Installation
  10. npm install colors
  11. ## colors and styles!
  12. ### text colors
  13. - black
  14. - red
  15. - green
  16. - yellow
  17. - blue
  18. - magenta
  19. - cyan
  20. - white
  21. - gray
  22. - grey
  23. ### bright text colors
  24. - brightRed
  25. - brightGreen
  26. - brightYellow
  27. - brightBlue
  28. - brightMagenta
  29. - brightCyan
  30. - brightWhite
  31. ### background colors
  32. - bgBlack
  33. - bgRed
  34. - bgGreen
  35. - bgYellow
  36. - bgBlue
  37. - bgMagenta
  38. - bgCyan
  39. - bgWhite
  40. - bgGray
  41. - bgGrey
  42. ### bright background colors
  43. - bgBrightRed
  44. - bgBrightGreen
  45. - bgBrightYellow
  46. - bgBrightBlue
  47. - bgBrightMagenta
  48. - bgBrightCyan
  49. - bgBrightWhite
  50. ### styles
  51. - reset
  52. - bold
  53. - dim
  54. - italic
  55. - underline
  56. - inverse
  57. - hidden
  58. - strikethrough
  59. ### extras
  60. - rainbow
  61. - zebra
  62. - america
  63. - trap
  64. - random
  65. ## Usage
  66. By popular demand, `colors` now ships with two types of usages!
  67. The super nifty way
  68. ```js
  69. var colors = require('colors');
  70. console.log('hello'.green); // outputs green text
  71. console.log('i like cake and pies'.underline.red) // outputs red underlined text
  72. console.log('inverse the color'.inverse); // inverses the color
  73. console.log('OMG Rainbows!'.rainbow); // rainbow
  74. console.log('Run the trap'.trap); // Drops the bass
  75. ```
  76. or a slightly less nifty way which doesn't extend `String.prototype`
  77. ```js
  78. var colors = require('colors/safe');
  79. console.log(colors.green('hello')); // outputs green text
  80. console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text
  81. console.log(colors.inverse('inverse the color')); // inverses the color
  82. console.log(colors.rainbow('OMG Rainbows!')); // rainbow
  83. console.log(colors.trap('Run the trap')); // Drops the bass
  84. ```
  85. I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
  86. 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.
  87. ## Enabling/Disabling Colors
  88. The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
  89. ```bash
  90. node myapp.js --no-color
  91. node myapp.js --color=false
  92. node myapp.js --color
  93. node myapp.js --color=true
  94. node myapp.js --color=always
  95. FORCE_COLOR=1 node myapp.js
  96. ```
  97. Or in code:
  98. ```javascript
  99. var colors = require('colors');
  100. colors.enable();
  101. colors.disable();
  102. ```
  103. ## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
  104. ```js
  105. var name = 'Marak';
  106. console.log(colors.green('Hello %s'), name);
  107. // outputs -> 'Hello Marak'
  108. ```
  109. ## Custom themes
  110. ### Using standard API
  111. ```js
  112. var colors = require('colors');
  113. colors.setTheme({
  114. silly: 'rainbow',
  115. input: 'grey',
  116. verbose: 'cyan',
  117. prompt: 'grey',
  118. info: 'green',
  119. data: 'grey',
  120. help: 'cyan',
  121. warn: 'yellow',
  122. debug: 'blue',
  123. error: 'red'
  124. });
  125. // outputs red text
  126. console.log("this is an error".error);
  127. // outputs yellow text
  128. console.log("this is a warning".warn);
  129. ```
  130. ### Using string safe API
  131. ```js
  132. var colors = require('colors/safe');
  133. // set single property
  134. var error = colors.red;
  135. error('this is red');
  136. // set theme
  137. colors.setTheme({
  138. silly: 'rainbow',
  139. input: 'grey',
  140. verbose: 'cyan',
  141. prompt: 'grey',
  142. info: 'green',
  143. data: 'grey',
  144. help: 'cyan',
  145. warn: 'yellow',
  146. debug: 'blue',
  147. error: 'red'
  148. });
  149. // outputs red text
  150. console.log(colors.error("this is an error"));
  151. // outputs yellow text
  152. console.log(colors.warn("this is a warning"));
  153. ```
  154. ### Combining Colors
  155. ```javascript
  156. var colors = require('colors');
  157. colors.setTheme({
  158. custom: ['red', 'underline']
  159. });
  160. console.log('test'.custom);
  161. ```
  162. *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*