Skip to content

Commit 0d2c2de

Browse files
committed
Fixed typo and cleaning
1 parent 84f13af commit 0d2c2de

File tree

2 files changed

+7
-49
lines changed

2 files changed

+7
-49
lines changed

flask_script/__init__.py

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
try:
2929
import argcomplete
30-
ARGCOMLETE_IMPORTED = True
30+
ARGCOMPLETE_IMPORTED = True
3131
except ImportError:
32-
ARGCOMLETE_IMPORTED = False
32+
ARGCOMPLETE_IMPORTED = False
3333

3434

3535
class Manager(object):
@@ -167,7 +167,7 @@ def _create_command(item):
167167

168168
## enable autocomplete only for parent parser when argcomplete is
169169
## imported and it is NOT disabled in constructor
170-
if parents is None and ARGCOMLETE_IMPORTED \
170+
if parents is None and ARGCOMPLETE_IMPORTED \
171171
and not self.disable_argcomplete:
172172
argcomplete.autocomplete(parser, always_complete_options=True)
173173

@@ -295,49 +295,6 @@ def _make_context(app):
295295

296296
return func
297297

298-
def get_usage(self):
299-
300-
"""
301-
Returns string consisting of all commands and their
302-
descriptions.
303-
"""
304-
pad = max(map(len, self._commands.iterkeys())) + 2
305-
format = ' %%- %ds%%s' % pad
306-
307-
rv = []
308-
309-
if self.usage:
310-
rv.append(self.usage)
311-
312-
for name, command in sorted(self._commands.iteritems()):
313-
usage = name
314-
315-
if isinstance(command, Manager):
316-
description = command.usage or ''
317-
else:
318-
description = command.description or ''
319-
320-
usage = format % (name, description)
321-
rv.append(usage)
322-
323-
return "\n".join(rv)
324-
325-
def print_usage(self):
326-
327-
"""
328-
Prints result of get_usage()
329-
"""
330-
331-
print self.get_usage()
332-
333-
def _handle(self, app, *args, **kwargs):
334-
"""
335-
Calling manager without command prints usage message.
336-
"""
337-
with app.test_request_context():
338-
self.print_usage()
339-
return 1
340-
341298
def handle(self, prog, args=None):
342299

343300
app_parser = self.create_parser(prog)

tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,16 @@ def test_get_usage(self):
318318
manager = Manager(self.app)
319319
manager.add_command('simple', SimpleCommand())
320320

321-
assert 'simple simple command' in manager.get_usage()
321+
usage = manager.create_parser('manage.py').format_help()
322+
assert 'simple command' in usage
322323

323324
def test_get_usage_with_specified_usage(self):
324325

325326
manager = Manager(self.app, usage='hello')
326327
manager.add_command('simple', SimpleCommand())
327328

328-
usage = manager.get_usage()
329-
assert 'simple simple command' in usage
329+
usage = manager.create_parser('manage.py').format_help()
330+
assert 'simple command' in usage
330331
assert 'hello' in usage
331332

332333
def test_run_existing_command(self):

0 commit comments

Comments
 (0)