Skip to content

Commit cc99690

Browse files
committed
CLI: comments and reorder
1 parent a25b793 commit cc99690

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/badges/__main__.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
log = logging.getLogger("badges")
99

1010

11+
# ---------- helper functions ----------------- #
1112
def _validate_color(ctx, param, val):
1213
if param.name == "color" and val is not None:
1314
if not utils.check_html_color(val):
@@ -29,6 +30,7 @@ def _change_logging(ctx, param, val):
2930
log.setLevel(logging.DEBUG)
3031

3132

33+
# ---------- command line interface ----------- #
3234
@click.group
3335
@click.help_option("-h", "--help")
3436
@click.version_option(
@@ -132,12 +134,6 @@ def create(text, color, icon_name, icon_file, output, label, output_type, style)
132134
"""Create a badge. Uses the given options to querry the shield.io API and
133135
returnes either the URL or the full svg data."""
134136

135-
if icon_name is not None:
136-
icon = icon_name
137-
138-
if icon_file is not None:
139-
icon = utils.convert_imagefile(icon_file)
140-
141137
if icon_name is not None and icon_file is not None:
142138
log.warning(
143139
"you are using both 'icon-name' and 'icon-file', but can only use one! "
@@ -149,6 +145,12 @@ def create(text, color, icon_name, icon_file, output, label, output_type, style)
149145
"missing 'icon-name', 'icon-file' and 'label', the badge might look wird."
150146
)
151147

148+
if icon_name is not None:
149+
icon = icon_name
150+
151+
if icon_file is not None:
152+
icon = utils.convert_imagefile(icon_file)
153+
152154
try:
153155
badge = api._create_badge(text, color, icon, label)
154156
except errors.BadgeCreationError as e:

0 commit comments

Comments
 (0)