From 17d3a0167df8b871c96c6401d601c89cfc15c8ed Mon Sep 17 00:00:00 2001 From: itec Date: Thu, 29 Oct 2020 16:34:28 +0100 Subject: [PATCH] encode minlength --- banana/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/banana/cli.py b/banana/cli.py index 2abc8de..034796b 100644 --- a/banana/cli.py +++ b/banana/cli.py @@ -27,7 +27,11 @@ def get_codec(args): def main_encode(args): - print(get_codec(args).encode(args.num)) + codec = get_codec(args) + kwargs = dict(num=args.num) + if args.minlength: + kwargs["minlength"] = args.minlength + print(codec.encode(**kwargs)) def main_decode(args): @@ -80,6 +84,7 @@ def main(): sub = parser.add_subparsers() encode = sub.add_parser("encode", help="Convert numbers to words") encode.add_argument("num", type=int) + encode.add_argument("--minlength", help="Set minimum length", type=int, default=6) encode.set_defaults(func=main_encode) decode = sub.add_parser("decode", help="Convert words to numbers")