feat: add version flag, fix --float parsing, and optimize distributions
This commit is contained in:
+14
-6
@@ -1,3 +1,5 @@
|
||||
import { VERSION } from "./types";
|
||||
|
||||
export const HELP = `rand — Generate random numbers
|
||||
|
||||
Usage:
|
||||
@@ -5,19 +7,20 @@ Usage:
|
||||
|
||||
Options:
|
||||
-c, --count <n> Number of random numbers to output (default: 1)
|
||||
-f[N] Decimal places: -f = -f2 (default: 2)
|
||||
-f[N] Decimal places: -f = -f2, -f3 = 3 places
|
||||
--float [N] Long form of -f
|
||||
-d, --dist <name> Distribution (default: uniform)
|
||||
-h, --help Show this help
|
||||
-V, --version Show version
|
||||
|
||||
Distributions and their positional args:
|
||||
uniform rand [min] [max] (default: 0 100)
|
||||
uniform rand [min] [max] (default: 0 100)
|
||||
normal rand -d normal [mean] [stddev] (default: 0 1)
|
||||
binomial rand -d binomial [n] [p] (default: 10 0.5)
|
||||
poisson rand -d poisson [lambda] (default: 1)
|
||||
exponential rand -d exponential [lambda] (default: 1)
|
||||
binomial rand -d binomial [n] [p] (default: 10 0.5)
|
||||
poisson rand -d poisson [lambda] (default: 1)
|
||||
exponential rand -d exponential [lambda] (default: 1)
|
||||
hypergeometric rand -d hypergeometric [N] [K] [n]
|
||||
(default: 100 50 10)
|
||||
(default: 100 50 10)
|
||||
|
||||
Examples:
|
||||
rand # uniform 0–100
|
||||
@@ -33,3 +36,8 @@ export function showHelp(): never {
|
||||
console.log(HELP);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
export function showVersion(): never {
|
||||
console.log(`rand v${VERSION}`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user