1
0
mirror of https://github.com/httpie/cli.git synced 2025-07-03 00:56:50 +02:00

more refinements

This commit is contained in:
Batuhan Taskaya
2022-05-19 14:56:25 +03:00
parent 5af4acc798
commit 0dce332b16
3 changed files with 126 additions and 133 deletions

View File

@ -35,9 +35,9 @@ def compile_zsh(node: Node) -> ...:
@compile_zsh.register(If)
def compile_if(node: If) -> str:
check = compile(node.check)
action = compile(node.action)
return f'if {check}; then\n {action};\nfi'
check = compile_zsh(node.check)
action = compile_zsh(node.action)
return f'if {check}; then\n {action} && ret=0\nfi'
@compile_zsh.register(Check)
@ -71,14 +71,17 @@ def compile_check(node: Check) -> str:
@compile_zsh.register(And)
def compile_and(node: And) -> str:
return ' && '.join(compile(check) for check in node.checks)
return ' && '.join(compile_zsh(check) for check in node.checks)
@compile_zsh.register(Not)
def compile_not(node: Not) -> str:
return f'! {compile(node.check)}'
return f'! {compile_zsh(node.check)}'
@compile_zsh.register(Suggest)
def compile_suggest(node: Suggest) -> str:
return SUGGESTION_TO_FUNCTION[node.suggestion]
for item in main_flow():
print(compile_zsh(item))