cli.js 511 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var helpText = ['Usage',
  4. ' $ window-size',
  5. '',
  6. 'Example',
  7. ' $ window-size',
  8. ' height: 40 ',
  9. ' width : 145',
  10. ''].join('\n');
  11. function showSize () {
  12. var size = require('./');
  13. console.log('height: ' + size.height);
  14. console.log('width : ' + size.width);
  15. }
  16. if (process.argv.length > 2) {
  17. switch (process.argv[2]) {
  18. case 'help':
  19. case '--help':
  20. case '-h':
  21. console.log(helpText);
  22. break;
  23. default:
  24. showSize();
  25. }
  26. } else {
  27. showSize();
  28. }