diff options
| author | Eric Lin <anselor@gmail.com> | 2018-04-24 19:35:34 -0400 |
|---|---|---|
| committer | Eric Lin <anselor@gmail.com> | 2018-04-24 19:35:34 -0400 |
| commit | 4193ef0344359d050bbfa469cbb898a52db97622 (patch) | |
| tree | 9bd7cd4f073af45671a0e25680238023073c96b8 /cmd2/__init__.py | |
| parent | f11b06374aaf56b755de33a763220140d36eab64 (diff) | |
| download | cmd2-git-4193ef0344359d050bbfa469cbb898a52db97622.tar.gz | |
Initial customization of CompletionFinder
Diffstat (limited to 'cmd2/__init__.py')
| -rw-r--r-- | cmd2/__init__.py | 17 |
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 |
