uuid 597 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env node
  2. var path = require('path');
  3. var uuid = require(path.join(__dirname, '..'));
  4. var arg = process.argv[2];
  5. if ('--help' === arg) {
  6. console.log('\n USAGE: uuid [version] [options]\n\n');
  7. console.log(' options:\n');
  8. console.log(' --help Display this message and exit\n');
  9. process.exit(0);
  10. }
  11. if (null == arg) {
  12. console.log(uuid());
  13. process.exit(0);
  14. }
  15. if ('v1' !== arg && 'v4' !== arg) {
  16. console.error('Version must be RFC4122 version 1 or version 4, denoted as "v1" or "v4"');
  17. process.exit(1);
  18. }
  19. console.log(uuid[arg]());
  20. process.exit(0);