mirror of
https://github.com/chubin/cheat.sh.git
synced 2026-06-20 05:06:44 +02:00
Merge pull request #318 from chubin/space-tests
Document unit tests and replace + and space handling logic with regexpx
This commit is contained in:
+4
-20
@@ -26,25 +26,10 @@ def _add_section_name(query):
|
||||
if '/' in query:
|
||||
return query
|
||||
if ' ' in query:
|
||||
delim = " "
|
||||
elif '+' in query:
|
||||
delim = "+"
|
||||
|
||||
index = 0
|
||||
length = len(query)
|
||||
while index != length:
|
||||
|
||||
index = query.index(delim, index) + 1
|
||||
|
||||
try:
|
||||
comparison = query.index(delim, index)
|
||||
except ValueError:
|
||||
comparison = -1
|
||||
|
||||
if (index != comparison and index != length):
|
||||
return "%s/%s" % (query[:index-1], query[index:])
|
||||
|
||||
return query
|
||||
return re.sub(r' +', '/', query, count=1)
|
||||
if '+' in query:
|
||||
# replace only single + to avoid catching g++ and friends
|
||||
return re.sub(r'([^\+])\+([^\+])', r'\1/\2', query, count=1)
|
||||
|
||||
def cheat_wrapper(query, request_options=None, output_format='ansi'):
|
||||
"""
|
||||
@@ -53,7 +38,6 @@ def cheat_wrapper(query, request_options=None, output_format='ansi'):
|
||||
Additional request options specified in `request_options`.
|
||||
"""
|
||||
|
||||
|
||||
def _rewrite_aliases(word):
|
||||
if word == ':bash.completion':
|
||||
return ':bash_completion'
|
||||
|
||||
@@ -13,12 +13,19 @@ btrfs~volume
|
||||
python/copy+file
|
||||
python/rosetta/:list
|
||||
emacs:go-mode/:list
|
||||
g++g++
|
||||
"""
|
||||
|
||||
split = """
|
||||
python copy file
|
||||
python/copy file
|
||||
|
||||
python file
|
||||
python/file
|
||||
|
||||
python+file
|
||||
python/file
|
||||
|
||||
g++ -O1
|
||||
g++/-O1
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
To run unit tests.
|
||||
|
||||
python3 -m pytest -v ../lib/
|
||||
|
||||
To run input/output tests.
|
||||
|
||||
./run-tests.sh
|
||||
Regular → Executable
Reference in New Issue
Block a user