diff options
Diffstat (limited to 'rl')
-rwxr-xr-x | rl | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -28,13 +28,21 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +import argparse import random import sys +parser = argparse.ArgumentParser(description='Process some integers.') +parser.add_argument('-s', '--sample', metavar='LINES', type=int, nargs='?', const=1, help='Print only this many lines (1).') +args = parser.parse_args() + lines = sys.stdin.readlines() -random.SystemRandom().shuffle(lines) +r = random.SystemRandom() +if args.sample is None: + r.shuffle(lines) +else: + lines = r.sample(lines, args.sample) for l in lines: print(l, end='') |