Skip to content

Commit c77a4ce

Browse files
committed
feat: add message to cli
1 parent 0eed61b commit c77a4ce

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

cli.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@ import { Hasher } from "./hasher.ts";
44

55
const isDeno = typeof (globalThis as any).Deno !== "undefined";
66

7-
const cmd = isDeno
8-
? "deno run https://deno.land/x/inthash/cli.ts"
9-
: "npx inthash";
7+
const cmd = isDeno ? "deno run jsr:@denostack/inthash/cli" : "npx inthash";
108

11-
const args = parse(
12-
isDeno
13-
? (globalThis as any).Deno.args
14-
: (globalThis as any).process.argv.slice(2),
15-
);
9+
const rawArgs = isDeno
10+
? (globalThis as any).Deno.args
11+
: (globalThis as any).process.argv.slice(2);
12+
const cmdSuffix = rawArgs.join(" ");
13+
const args = parse(rawArgs);
1614

17-
const options = Hasher.generate(args.b ?? args.bit ?? args.bits ?? 53);
15+
const bit = args.b ?? args.bit ?? args.bits ?? 53;
16+
const options = Hasher.generate(bit);
1817

1918
console.log(JSON.stringify(options, null, " "));
2019
console.error(`
20+
$ ${cmd}${cmdSuffix ? " " + cmdSuffix : ""} | pbcopy
2121
22-
$ ${cmd} | pbcopy
22+
Now go ahead and paste it into your code! Good luck. :-)
2323
24-
then paste to your code! :-) good luck.`);
24+
Note: The supported range of integers is from min: 0 to max: ${
25+
(1n << BigInt(bit)) - 1n
26+
}.
27+
Please make sure your inputs fall within this range.`);
2528

2629
type Args = {
2730
b?: number;

0 commit comments

Comments
 (0)