Skip to content

Instantly share code, notes, and snippets.

@legionus
Created September 7, 2023 09:22
Show Gist options
  • Save legionus/798721787f1dce8e77e6c1d97cd6a70f to your computer and use it in GitHub Desktop.
Save legionus/798721787f1dce8e77e6c1d97cd6a70f to your computer and use it in GitHub Desktop.
def process_commands(payload):
fd = io.StringIO(initial_value=payload, newline='\n')
while True:
value = fd.readline()
if not value:
break
value = value[:-1]
if not re.match(r'^\s*jira\s+', value, re.I):
continue
words = [ x for x in re.split(r'("[^"]+"|\'[^\']+\'|\S+)', value) if len(x.strip()) > 0 ]
for i, word in enumerate(words):
if word.startswith("<<"):
token = word[2:]
heredoc = []
while True:
s = fd.readline()
if not s:
break
if s[:-1] == token:
break
heredoc.append(s)
words[i] = "".join(heredoc)
print(words)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment