Skip to content

Commit

Permalink
Fix probability argument for random command
Browse files Browse the repository at this point in the history
  • Loading branch information
juffalow committed Oct 31, 2020
1 parent a62e334 commit ddc014c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ program
.description(`
List all URLs in sitemap.
`)
.option('--probability', 'the chance the line will pass', '10')
.action(() => {
.option('--probability <probability>', 'the chance the line will pass', (value) => parseInt(value))
.action((options) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
Expand All @@ -75,7 +75,7 @@ program
rl.on('line', (line) => {
try {
new URL(line);
if (Math.random() <= 0.1) {
if (Math.random() <= (options.probability / 100)) {
console.log(line);
}
} catch {
Expand Down

0 comments on commit ddc014c

Please sign in to comment.