[79a0317] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | const assert = require("assert");
|
---|
| 4 | const v1_js_1 = require("./v1.js");
|
---|
| 5 | const v3_js_1 = require("./v3.js");
|
---|
| 6 | const v4_js_1 = require("./v4.js");
|
---|
| 7 | const v5_js_1 = require("./v5.js");
|
---|
| 8 | const v6_js_1 = require("./v6.js");
|
---|
| 9 | const v7_js_1 = require("./v7.js");
|
---|
| 10 | function usage() {
|
---|
| 11 | console.log('Usage:');
|
---|
| 12 | console.log(' uuid');
|
---|
| 13 | console.log(' uuid v1');
|
---|
| 14 | console.log(' uuid v3 <name> <namespace uuid>');
|
---|
| 15 | console.log(' uuid v4');
|
---|
| 16 | console.log(' uuid v5 <name> <namespace uuid>');
|
---|
| 17 | console.log(' uuid v6');
|
---|
| 18 | console.log(' uuid v7');
|
---|
| 19 | console.log(' uuid --help');
|
---|
| 20 | console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC9562');
|
---|
| 21 | }
|
---|
| 22 | const args = process.argv.slice(2);
|
---|
| 23 | if (args.indexOf('--help') >= 0) {
|
---|
| 24 | usage();
|
---|
| 25 | process.exit(0);
|
---|
| 26 | }
|
---|
| 27 | const version = args.shift() || 'v4';
|
---|
| 28 | switch (version) {
|
---|
| 29 | case 'v1':
|
---|
| 30 | console.log((0, v1_js_1.default)());
|
---|
| 31 | break;
|
---|
| 32 | case 'v3': {
|
---|
| 33 | const name = args.shift();
|
---|
| 34 | let namespace = args.shift();
|
---|
| 35 | assert.ok(name != null, 'v3 name not specified');
|
---|
| 36 | assert.ok(namespace != null, 'v3 namespace not specified');
|
---|
| 37 | if (namespace === 'URL') {
|
---|
| 38 | namespace = v3_js_1.default.URL;
|
---|
| 39 | }
|
---|
| 40 | if (namespace === 'DNS') {
|
---|
| 41 | namespace = v3_js_1.default.DNS;
|
---|
| 42 | }
|
---|
| 43 | console.log((0, v3_js_1.default)(name, namespace));
|
---|
| 44 | break;
|
---|
| 45 | }
|
---|
| 46 | case 'v4':
|
---|
| 47 | console.log((0, v4_js_1.default)());
|
---|
| 48 | break;
|
---|
| 49 | case 'v5': {
|
---|
| 50 | const name = args.shift();
|
---|
| 51 | let namespace = args.shift();
|
---|
| 52 | assert.ok(name != null, 'v5 name not specified');
|
---|
| 53 | assert.ok(namespace != null, 'v5 namespace not specified');
|
---|
| 54 | if (namespace === 'URL') {
|
---|
| 55 | namespace = v5_js_1.default.URL;
|
---|
| 56 | }
|
---|
| 57 | if (namespace === 'DNS') {
|
---|
| 58 | namespace = v5_js_1.default.DNS;
|
---|
| 59 | }
|
---|
| 60 | console.log((0, v5_js_1.default)(name, namespace));
|
---|
| 61 | break;
|
---|
| 62 | }
|
---|
| 63 | case 'v6':
|
---|
| 64 | console.log((0, v6_js_1.default)());
|
---|
| 65 | break;
|
---|
| 66 | case 'v7':
|
---|
| 67 | console.log((0, v7_js_1.default)());
|
---|
| 68 | break;
|
---|
| 69 | default:
|
---|
| 70 | usage();
|
---|
| 71 | process.exit(1);
|
---|
| 72 | }
|
---|