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

Thor should return nonzero exit status when a task is not found #56

Closed
fj opened this issue Aug 14, 2010 · 8 comments
Closed

Thor should return nonzero exit status when a task is not found #56

fj opened this issue Aug 14, 2010 · 8 comments

Comments

@fj
Copy link

fj commented Aug 14, 2010

Consider a simple Thor class:

class Foo < Thor
  no_tasks do
    def initialize(*)
      super
    end

    def exit_on_failure?; true; end
  end

  def arbitrary; shell.say "invoked"; end
end

When I run a binary foo_runner that uses this class and a task is not found, I get a zero status code. This is not the expected behavior; I want to see a nonzero status code if a task is not found.

$ foo_runner arbitrary; echo $?
invoked
0

$ foo_runner missing_command; echo $?
Could not find task "missing_command".
0  # <-- Expected nonzero return value here.
@tpitale
Copy link

tpitale commented Aug 14, 2010

+1

@eventualbuddha
Copy link
Contributor

Could you also post the source of the foo_runner binary so we'll have a full test case?

@fj
Copy link
Author

fj commented Aug 16, 2010

foo_runner is just Foo.start.

@eventualbuddha
Copy link
Contributor

So it looks like this?

#!/usr/bin/env ruby
Foo.start

@fj
Copy link
Author

fj commented Aug 20, 2010

Here's a simple class you can use for a test case:

#!/usr/bin/env ruby
require 'thor'

class Foo < Thor
  no_tasks do
    def initialize(*)
      super
    end

    def exit_on_failure?; true; end
  end

  desc "arbitrary", "a simple task"
  def arbitrary; shell.say "invoked"; end
end

Foo.start

At the command line:

$ chmod +x foo_runner.rb

$ ./foo_runner.rb arbitrary; echo $?
invoked
0    # <-- Expected 0, got 0. Pass.

$ ./foo_runner.rb kablammo; echo $?
Could not find task "kablammo".
0    # <-- Expected non-zero, got 0. Fail.

@josevalim
Copy link
Contributor

Patch please!

@ldenman
Copy link

ldenman commented Apr 5, 2012

Two years later and I am wondering if a fix for this was ever implemented?

Thanks.

@akahn
Copy link

akahn commented Jul 12, 2012

This was supposedly fixed for #1 in 0229237. @josevalim, is the purpose of exit_on_failure? to allow different classes to configure whether or not they exit on failure? Would it be acceptable to change the default to true?

This issue was closed.
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

6 participants