Skip to content
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

Builtin Outputs #249

Merged
merged 4 commits into from
Nov 15, 2023
Merged

Builtin Outputs #249

merged 4 commits into from
Nov 15, 2023

Conversation

nithinmuthukumar
Copy link
Collaborator

This PR is aiming to solve #246 by making builtin commands return CmdOutput.
The output of each builtin is captured into a CmdOutput and can be sent to hooks.

@nithinmuthukumar nithinmuthukumar marked this pull request as ready for review November 7, 2023 03:56
Copy link
Owner

@MrPicklePinosaur MrPicklePinosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, definitely needs more user friendly and less error prone way of outputting though

@nithinmuthukumar
Copy link
Collaborator Author

nithinmuthukumar commented Nov 15, 2023

Now this PR is aiming to use OutputWriter to simplify the collection of output by making it automatic. Shell.rs automatically calls ctx.out.begin_collecting() and ctx.out.end_collecting(). All output should now be done using OutputWriter. CmdOutput is no longer constructed with output but rather only with the status. The output is later retrieved from OutputWriter and added to CmdOutput

Copy link
Owner

@MrPicklePinosaur MrPicklePinosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. maybe some further thought can be put in on a unified output system in the future but this can do for now

@@ -35,8 +36,8 @@ impl BuiltinCmd for CdBuiltin {
if let Ok(old_pwd) = rt.env.get("OLDPWD") {
PathBuf::from(old_pwd)
} else {
eprintln!("no OLDPWD");
return Ok(BuiltinStatus::error());
ctx.out.eprintln("no OLDPWD")?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still have the ability to format strings? is it still a variadic function

Copy link
Collaborator Author

@nithinmuthukumar nithinmuthukumar Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will make it variadic, good idea

@nithinmuthukumar nithinmuthukumar merged commit 0e6a634 into master Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants