-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features/env, source and exec commands + basic unix pipelines #73
Features/env, source and exec commands + basic unix pipelines #73
Conversation
…ompt console compatible format
…ve the last environment state to a single file) - Added handling of FileNotFoundError
…mand output logging to a console & writing to a file
…ng data to a file
@fogine This is a really awesome work! Thank you for putting the effort here. This PR will take me a while to do a full review. However, I have some initial thoughts here.
class ExecutionVisitor(NodeVisitor):
def __init__(self, context, listener=None):
# ...
self.output = sys.stdout # Defaults to stdout
def visit_redir_file(self, node, children):
path = ... # Get destination file path from node
self.output = open(path, 'w')
|
I'll try to make the changes later today. Thank you for the feedback @eliangcs |
import click | ||
|
||
|
||
class Printer(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's not necessary to use the click
library due to compatibility reasons, we can write directly to stdout
.... I guess it's better this way...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fogine Instead of using sys.stdout
directly, I think you should use click.echo_via_pager
whenever you want to write to stdout. Sorry, it was my bad in the example code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eliangcs , no problem, it's already using click.echo_via_pager
, I was just stressing it out in case there would be better solution and I haven't known about it... never mind...
@fogine I got an error on the
However, when I use |
@@ -10,14 +10,17 @@ | |||
|
|||
from http_prompt.context import Context | |||
from http_prompt.execution import execute | |||
from http_prompt.xdg import get_tmp_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python already has a tempfile module that can be used to manage temporary files and directories. So writing a get_tmp_dir
in http_prompt.xdg
is not really necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed this recently and haven't had time to rewrite this yet... I will.
@eliangcs, what's the output of the |
I think the error happens here: https://github.com/eliangcs/http-prompt/pull/73/files#diff-14f61a2e4ef220b7fe763cda57fec637R17, where |
…k.echo_via_pager` module method
…g` module so that the tests use the `TempAppDirTestCase` module
@fogine Thanks for fixing the |
@eliangcs , fixed & test case added... |
Merged. Thanks for your contribution, @fogine! I'd like to refactor the code a bit, but I guess I can do that later. |
No problem. I'm interested in seeing how I can improve my possible future contributions. Thank you for your support during the development, @eliangcs ! |
Solves #70
Adds new commands:
env
,source
,exec
Adds output redirection feature:
Changed behavior of automatic context saving... It saves only current session to single file. It's like backup of a unsaved session.
Covered by tests
Readme file with starting guide updated... so it reflects the new features