Skip to content

Exiting from pre_run hooks #13

@devnote-dev

Description

@devnote-dev

For pre_run hook methods, there is the option to stop command execution to the main run method if the value returned is false. However, there are no checks in place to determine the actual exit code for this, the Executor simply returns which results in a 0 exit code:

begin
res = resolved_command.pre_run executed.parsed_arguments, executed.parsed_options
return unless res.nil? || res

This is obviously not ideal and even misleading for people designing applications that rely on the exit code for debugging or informational purposes. There are already ways to get around this, for example, raising a specific exception that gets funneled to the on_error hook method which then terminates the program with the appropriate exit code. But I think there should be a better way of doing this, even if it's just a shorthand method built into the Command class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions