Skip to content

Add an option to suppress final error output #396

Description

@cgruber

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.

Activity

  1. chardskarth commented on Feb 22, 2023

    @chardskarth

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

  2. aartiPl commented on Apr 2, 2023

    @aartiPl
    Collaborator

    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.

  3. cgruber commented on Apr 3, 2023

    @cgruber
    Author

    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.

  4. cgruber commented on Jun 20, 2023

    @cgruber
    Author

    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.

  5. aartiPl commented on Jun 21, 2023

    @aartiPl
    Collaborator

    @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.

  6. aartiPl commented on Jun 22, 2023

    @aartiPl
    Collaborator

    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.

  7. cgruber commented on Jun 22, 2023

    @cgruber
    Author
  8. aartiPl commented on Jun 22, 2023

    @aartiPl
    Collaborator

    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 :-)

  9. chardskarth commented on Oct 24, 2023

    @chardskarth

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

  10. cgruber commented on Oct 24, 2023

    @cgruber
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions