Skip to content

Commit 429799b

Browse files
committed
Show messages for venv, publish, change commands.
1 parent b39aa5d commit 429799b

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

src/makeapp/cli.py

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
sys.exit()
1919

2020

21+
option_debug = click.option(
22+
'--debug',
23+
help='Show debug messages while processing', is_flag=True
24+
)
25+
26+
2127
@click.group()
2228
@click.version_option(version=VERSION)
2329
def entry_point():
@@ -33,9 +39,7 @@ def entry_point():
3339
)
3440
@click.argument('app_name')
3541
@click.argument('target_path')
36-
@click.option(
37-
'--debug', is_flag=True,
38-
help='Show debug messages while processing')
42+
@option_debug
3943
@click.option(
4044
'-d', '--description',
4145
help='Short application description')
@@ -90,11 +94,7 @@ def process_custom_args(args):
9094
'templates_to_use': (kwargs['templates_to_use'] or '').split(',') or None,
9195
}
9296

93-
log_level = None
94-
if debug:
95-
log_level = logging.DEBUG
96-
97-
app_maker = AppMaker(app_name, log_level=log_level, **app_maker_kwargs)
97+
app_maker = AppMaker(app_name, log_level=logging.DEBUG if debug else None, **app_maker_kwargs)
9898

9999
app_maker.update_settings_complex(
100100
config=configuration_file,
@@ -149,16 +149,10 @@ def process_custom_args(args):
149149
'-i', '--increment',
150150
help='Version number chunk to increment', type=click.Choice(VERSION_NUMBER_CHUNKS)
151151
)
152-
@click.option(
153-
'--debug',
154-
help='Show debug messages while processing', is_flag=True
155-
)
152+
@option_debug
156153
def release(increment, debug):
157154
"""Performs new application version release."""
158-
if debug:
159-
configure_logging(logging.DEBUG)
160-
161-
project = Project()
155+
project = Project(log_level=logging.DEBUG if debug else logging.INFO)
162156

163157
project.pull()
164158

@@ -182,25 +176,22 @@ def release(increment, debug):
182176

183177

184178
@entry_point.command()
185-
@click.option(
186-
'--debug',
187-
help='Show debug messages while processing', is_flag=True
188-
)
179+
@option_debug
189180
def publish(debug):
190181
"""Publishes current version to remotes."""
191-
if debug:
192-
configure_logging(logging.DEBUG)
193-
194-
project = Project()
182+
project = Project(log_level=logging.DEBUG if debug else logging.INFO)
195183
project.pull()
196184
project.publish()
197185

186+
click.secho('Done', fg='green')
187+
198188

199189
@entry_point.command()
190+
@option_debug
200191
@click.argument('description', nargs=-1)
201-
def change(description):
192+
def change(debug, description):
202193
"""Fixates a change adding a message to a changelog."""
203-
Project().add_change(description)
194+
Project(log_level=logging.DEBUG if debug else logging.INFO).add_change(description)
204195
click.secho('Done', fg='green')
205196

206197

@@ -210,9 +201,10 @@ def venv():
210201

211202

212203
@venv.command()
213-
def reset():
204+
@option_debug
205+
def reset(debug):
214206
"""Remove old virtual environment and generate a new one."""
215-
Project().venv_init(reset=True)
207+
Project(log_level=logging.DEBUG if debug else logging.INFO).venv_init(reset=True)
216208

217209

218210
def main():

0 commit comments

Comments
 (0)