summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/__init__.py2
-rw-r--r--cmd2/argcomplete_bridge.py14
-rwxr-xr-xexamples/alias_startup.py4
-rwxr-xr-xexamples/help_categories.py3
4 files changed, 8 insertions, 15 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py
index d3d193cf..bf6c047f 100644
--- a/cmd2/__init__.py
+++ b/cmd2/__init__.py
@@ -1,4 +1,2 @@
#
# -*- coding: utf-8 -*-
-
-
diff --git a/cmd2/argcomplete_bridge.py b/cmd2/argcomplete_bridge.py
index 5383ebec..583f3345 100644
--- a/cmd2/argcomplete_bridge.py
+++ b/cmd2/argcomplete_bridge.py
@@ -148,16 +148,15 @@ else:
# not an argument completion invocation
return
- global debug_stream
try:
- debug_stream = os.fdopen(9, "w")
- except:
- debug_stream = sys.stderr
+ argcomplete.debug_stream = os.fdopen(9, "w")
+ except IOError:
+ argcomplete.debug_stream = sys.stderr
if output_stream is None:
try:
output_stream = os.fdopen(8, "wb")
- except:
+ except IOError:
argcomplete.debug("Unable to open fd 8 for writing, quitting")
exit_method(1)
@@ -234,7 +233,7 @@ else:
# to ever match.
outstr = outstr.replace('\n', ' ').replace('\t', ' ').replace(' ', ' ').strip()
# generate a filler entry that should always sort first
- filler = ' {0:><{width}}'.format('', width=len(outstr))
+ filler = ' {0:><{width}}'.format('', width=len(outstr)/2)
outstr = ifs.join([filler, outstr])
output_stream.write(outstr.encode(argcomplete.sys_encoding))
@@ -243,6 +242,5 @@ else:
# go forward with normal filesystem completion
output_stream.write(ifs.join([]).encode(argcomplete.sys_encoding))
output_stream.flush()
- debug_stream.flush()
+ argcomplete.debug_stream.flush()
exit_method(0)
-
diff --git a/examples/alias_startup.py b/examples/alias_startup.py
index a02972b6..7ccfa6e5 100755
--- a/examples/alias_startup.py
+++ b/examples/alias_startup.py
@@ -4,12 +4,8 @@
1) How to add custom command aliases using the alias command
2) How to load an initialization script at startup
"""
-import argparse
from cmd2 import cmd2
-import pyparsing
-
-from cmd2.cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args
class AliasAndStartup(cmd2.Cmd):
diff --git a/examples/help_categories.py b/examples/help_categories.py
index 7adedb51..dcfbd31f 100755
--- a/examples/help_categories.py
+++ b/examples/help_categories.py
@@ -4,9 +4,10 @@
A sample application for tagging categories on commands.
"""
-from cmd2.cmd2 import Cmd, categorize, __version__, with_argparser, with_category
import argparse
+from cmd2.cmd2 import Cmd, categorize, __version__, with_argparser, with_category
+
class HelpCategories(Cmd):
""" Example cmd2 application. """