diff --git a/README.md b/README.md index 3822acf..031827a 100644 --- a/README.md +++ b/README.md @@ -206,44 +206,50 @@ anybadge --label=awesomeness --value="110%" --file=awesomeness.svg --color=#97CA These are the command line options: ``` - positional arguments: - args Pairs of =. For example 2=red 4=orange - 6=yellow 8=good. Read this as "Less than 2 = red, less - than 4 = orange...". - - optional arguments: - -h, --help show this help message and exit - -l LABEL, --label LABEL - The badge label. - -v VALUE, --value VALUE - The badge value. - -m VALUE_FORMAT, --value-format VALUE_FORMAT - Formatting string for value (e.g. "%.2f" for 2dp - floats) - -c COLOR, --color COLOR - For fixed color badges use --colorto specify the badge - color. - -p PREFIX, --prefix PREFIX - Optional prefix for value. - -s SUFFIX, --suffix SUFFIX - Optional suffix for value. - -d PADDING, --padding PADDING - Number of characters to pad on either side of the - badge text. - -n FONT, --font FONT "DejaVu Sans,Verdana,Geneva,sans-serif" - -z FONT_SIZE, --font-size FONT_SIZE - Font size. - -t TEMPLATE, --template TEMPLATE - Location of alternative template .svg file. - -u, --use-max Use the maximum threshold color when the value exceeds - the maximum threshold. - -f FILE, --file FILE Output file location. - -o, --overwrite Overwrite output file if it already exists. - -r TEXT_COLOR, --text-color TEXT_COLOR - Text color. Single value affects both labeland value - colors. A comma separated pair affects label and value - text respectively. +positional arguments: + args Pairs of =. For example 2=red 4=orange + 6=yellow 8=good. Read this as "Less than 2 = red, less + than 4 = orange...". +optional arguments: + -h, --help show this help message and exit + -l LABEL, --label LABEL + The badge label. + -v VALUE, --value VALUE + The badge value. + -m VALUE_FORMAT, --value-format VALUE_FORMAT + Formatting string for value (e.g. "%.2f" for 2dp + floats) + -c COLOR, --color COLOR + For fixed color badges use --colorto specify the badge + color. + -p PREFIX, --prefix PREFIX + Optional prefix for value. + -s SUFFIX, --suffix SUFFIX + Optional suffix for value. + -d PADDING, --padding PADDING + Number of characters to pad on either side of the + badge text. + -lp LABEL_PADDING, --label-padding LABEL_PADDING + Number of characters to pad on either side of the + badge label. + -vp VALUE_PADDING, --value-padding VALUE_PADDING + Number of characters to pad on either side of the + badge value. + -n FONT, --font FONT "DejaVu Sans,Verdana,Geneva,sans-serif"Font name. + Supported fonts: ,"Arial, Helvetica, sans-serif" + -z FONT_SIZE, --font-size FONT_SIZE + Font size. + -t TEMPLATE, --template TEMPLATE + Location of alternative template .svg file. + -u, --use-max Use the maximum threshold color when the value exceeds + the maximum threshold. + -f FILE, --file FILE Output file location. + -o, --overwrite Overwrite output file if it already exists. + -r TEXT_COLOR, --text-color TEXT_COLOR + Text color. Single value affects both labeland value + colors. A comma separated pair affects label and value + text respectively. Examples -------- diff --git a/anybadge.py b/anybadge.py index 549a3f5..7537c08 100755 --- a/anybadge.py +++ b/anybadge.py @@ -763,6 +763,10 @@ examples: parser.add_argument('-d', '--padding', type=int, help='Number of characters to pad on ' 'either side of the badge text.', default=NUM_PADDING_CHARS) + parser.add_argument('-lp', '--label-padding', type=int, help='Number of characters to pad on ' + 'either side of the badge label.', default=None) + parser.add_argument('-vp', '--value-padding', type=int, help='Number of characters to pad on ' + 'either side of the badge value.', default=None) parser.add_argument('-n', '--font', type=str, help='Font name. Supported fonts: ' ','.join(['"%s"' % x for x in FONT_WIDTHS.keys()]), @@ -788,7 +792,7 @@ examples: return parser.parse_args(args) -def main(args): +def main(args=None): """Generate a badge based on command line arguments.""" # Args may be sent from command line of as args directly. @@ -822,8 +826,9 @@ def main(args): # Create badge object badge = Badge(label, args.value, value_prefix=args.prefix, value_suffix=suffix, - default_color=args.color, num_padding_chars=args.padding, font_name=args.font, - font_size=args.font_size, template=args.template, + default_color=args.color, num_padding_chars=args.padding, + num_label_padding_chars=args.label_padding, num_value_padding_chars=args.value_padding, + font_name=args.font, font_size=args.font_size, template=args.template, use_max_when_value_exceeds=args.use_max, thresholds=threshold_dict, value_format=args.value_format, text_color=args.text_color)