summaryrefslogtreecommitdiff
path: root/rl
diff options
context:
space:
mode:
Diffstat (limited to 'rl')
-rwxr-xr-xrl12
1 files changed, 10 insertions, 2 deletions
diff --git a/rl b/rl
index 316e23c..e5a6a92 100755
--- a/rl
+++ b/rl
@@ -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='')