Front end of the Slack clone application.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var fs = require('fs');
  4. var stdin = require('get-stdin');
  5. var pkg = require('./package.json');
  6. var stripIndent = require('./');
  7. var argv = process.argv.slice(2);
  8. var input = argv[0];
  9. function help() {
  10. console.log([
  11. '',
  12. ' ' + pkg.description,
  13. '',
  14. ' Usage',
  15. ' strip-indent <file>',
  16. ' echo <string> | strip-indent',
  17. '',
  18. ' Example',
  19. ' echo \'\\tunicorn\\n\\t\\tcake\' | strip-indent',
  20. ' unicorn',
  21. ' \tcake'
  22. ].join('\n'));
  23. }
  24. function init(data) {
  25. console.log(stripIndent(data));
  26. }
  27. if (argv.indexOf('--help') !== -1) {
  28. help();
  29. return;
  30. }
  31. if (argv.indexOf('--version') !== -1) {
  32. console.log(pkg.version);
  33. return;
  34. }
  35. if (process.stdin.isTTY) {
  36. if (!input) {
  37. help();
  38. return;
  39. }
  40. init(fs.readFileSync(input, 'utf8'));
  41. } else {
  42. stdin(init);
  43. }