Files
rand-cli/src/help.ts
T

44 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { VERSION } from "./types";
export const HELP = `rand — Generate random numbers
Usage:
rand [options] [args]
Options:
-c, --count <n> Number of random numbers to output (default: 1)
-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)
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)
hypergeometric rand -d hypergeometric [N] [K] [n]
(default: 100 50 10)
Examples:
rand # uniform 0100
rand -d normal # normal μ=0, σ=1
rand -d normal 100 15 -f1 # normal μ=100, σ=15, 1 decimal
rand -d binomial 20 0.3 -c 5 # 5 binomial(n=20, p=0.3)
rand -d poisson 3 # poisson λ=3
rand -d exponential 0.5 # exponential λ=0.5
echo "5 2" | rand -d normal # stdin overrides positional args
rand | xargs echo # pipe output`;
export function showHelp(): never {
console.log(HELP);
process.exit(0);
}
export function showVersion(): never {
console.log(`rand v${VERSION}`);
process.exit(0);
}