randomize/src/randomize.nim

28 lines
680 B
Nim

# This is just an example to get you started. A typical binary package
# uses this file as the main entry point of the application.
import std/random, std/strutils
import docopt
when isMainModule:
let doc = """
randomize
Usage:
randomize [options] <value>...
Options:
-h --help Show this usage information.
-c --choose <count> Choose <count> at random from the given input.
"""
let args = docopt(doc, version = "randomized 0.1.0")
randomize()
var randomized = @(args["<value>"])
shuffle(randomized )
let numToChoose =
if args["--choose"]: parseInt($args["--choose"])
else: randomized.len
echo randomized[0..<numToChoose].join("\p")