#! /usr/bin/env python3
"""Generate random integers:

  # generate random integer between 0 and 100
  $ randn 100

  # generate random integer between 20 and 100
  $ randn 20 100
"""
import argparse
import random
import sys


def main():
    # parse
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    parser.add_argument("a", type=int, help="minimum number (inclusive)")
    parser.add_argument(
        "b",
        nargs="?",
        type=int,
        help="maximum number (inclusive); If not given, then `a` would become range max.",
    )
    args = parser.parse_args()

    # output
    if args.b is None:
        min_, max_ = 0, args.a
    else:
        min_, max_ = args.a, args.b
    print(random.randint(min_, max_))


if __name__ == "__main__":
    sys.exit(main())
