summaryrefslogtreecommitdiff
path: root/cmd2/__init__.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2018-04-24 19:35:34 -0400
committerEric Lin <anselor@gmail.com>2018-04-24 19:35:34 -0400
commit4193ef0344359d050bbfa469cbb898a52db97622 (patch)
tree9bd7cd4f073af45671a0e25680238023073c96b8 /cmd2/__init__.py
parentf11b06374aaf56b755de33a763220140d36eab64 (diff)
downloadcmd2-git-4193ef0344359d050bbfa469cbb898a52db97622.tar.gz
Initial customization of CompletionFinder
Diffstat (limited to 'cmd2/__init__.py')
-rw-r--r--cmd2/__init__.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py
index 8e744e03..773eba37 100644
--- a/cmd2/__init__.py
+++ b/cmd2/__init__.py
@@ -3,3 +3,20 @@
#
from .cmd2 import __version__, Cmd, set_posix_shlex, set_strip_quotes, AddSubmenu, CmdResult, categorize
from .cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args, with_category
+
+# Used for tab completion and word breaks. Do not change.
+QUOTES = ['"', "'"]
+REDIRECTION_CHARS = ['|', '<', '>']
+
+
+def strip_quotes(arg: str) -> str:
+ """ Strip outer quotes from a string.
+
+ Applies to both single and double quotes.
+
+ :param arg: string to strip outer quotes from
+ :return: same string with potentially outer quotes stripped
+ """
+ if len(arg) > 1 and arg[0] == arg[-1] and arg[0] in QUOTES:
+ arg = arg[1:-1]
+ return arg