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

Add an option to suppress final error output #396

Open
cgruber opened this issue Feb 21, 2023 · 10 comments
Open

Add an option to suppress final error output #396

cgruber opened this issue Feb 21, 2023 · 10 comments

Comments

@cgruber
Copy link

cgruber commented Feb 21, 2023

In some contexts, you don't want kscript to print a "[ERROR] Execution of scriplet failed:" with the command output, since the error information is all supplied by the script. Either adding this to --silent or providing a separate suppression option would be great. Otherwise, some scripts which are intended to fail in normal operations (i.e. CI scripts) will be extra noisy despite behaving as expected.

@chardskarth
Copy link

chardskarth commented Feb 22, 2023

Need this as well! I'd be interested in submitting a PR @holgerbrandl if you need help on this one.

@aartiPl
Copy link
Collaborator

aartiPl commented Apr 2, 2023

Should we suppress the error message completely, even in silent mode? I think it would be better to print a single line with an error message even if silent mode is enabled. To achieve that it would involve implementing a custom Exception class, which can keep a message and detailed description of the problem. Then in logger in silent mode, we can just print the message without description and stack trace.

I will be happy to apply PR if you can provide it.

@cgruber
Copy link
Author

cgruber commented Apr 3, 2023

I think the point here is that there be no line at all - to leave all output to the explicit actions of the script developer's code, rather than the kscript framework. Maybe --silent isn't the right key here - maybe some other word conveys it.

I could try to whip something up, though I'm not familiar with kscript - I'm sure I could figure out where the output is generated and suppress there.

@cgruber
Copy link
Author

cgruber commented Jun 20, 2023

Any action on this? I'm also willing to maybe put in some time on it, but I am swamped right now coming back from being sick, so I don't know how much value I can bring here in the immediate term. But if no one does this soon-ish, I may need to. We're using kscript increasingly in our test and ops infrastructure, and I would really like to be able to have more control over output, especially where we are purposely exiting non-zero (for posix pipe purposes) and managing output ourselves in the script.

@aartiPl
Copy link
Collaborator

aartiPl commented Jun 21, 2023

@cgruber - I am concentrating on another project, which you might also be interested in, according to what you say above. The new project will allow access from scripts to many different command line tools like git, gradle, lxc, etc. From that point of view, I would prefer if anyone could implement correctly the "-s, --silent" feature in kscript. It shouldn't be difficult as the code is quite simple and, I hope, understandable. I agree with the previous comments: the feature should disable any output which comes from kscript, including e.g. information about the resolution of dependencies.

If you are able to spend some time developing this feature, feel free to branch out from the kscript_4.3 branch (which now just reflects the master branch) and implement the feature over there.

@aartiPl
Copy link
Collaborator

aartiPl commented Jun 22, 2023

I even think that the -s, --silent should be the default (so in fact this option should be removed), and then if the user needs additional logging he/she needs to add option either -v, --verbose for more logs, and -d, --development for very detailed logging.

This way it will be much easier to handle scripts with shebang line:
#!/usr/bin/env kscript
as the default will be silent mode.

@cgruber
Copy link
Author

cgruber commented Jun 22, 2023 via email

@aartiPl
Copy link
Collaborator

aartiPl commented Jun 22, 2023

I remember it is possible, but I need to remember how. That was a suggestion, so feel free to skip it, as it won't change anything in the current kscript behavior. The drawback of using --silent as a default is that we will not understand anything about why the script has failed. So maybe it is not that good idea after all :-)

@chardskarth
Copy link

We're you able to remember how you did it now? 😅 @aartiPl

@cgruber
Copy link
Author

cgruber commented Oct 24, 2023 via email

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

No branches or pull requests

3 participants