forked from voxpupuli/modulesync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: Force thor to exit with a correct exit status
Long-time issues on Thor related to exit status code cause msync to return a inappropriate exit code. As example: rails/thor#244
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'thor' | ||
require 'modulesync/cli' | ||
|
||
module ModuleSync | ||
module CLI | ||
# Workaround some, still unfixed, Thor behaviors | ||
# | ||
# This class extends ::Thor class to | ||
# - exit with status code sets to `1` on Thor failure (e.g. missing required option) | ||
# - exit with status code sets to `1` when user calls `msync` (or a subcommand) without required arguments | ||
class Thor < ::Thor | ||
desc '_invalid_command_call', 'Invalid command', hide: true | ||
def _invalid_command_call | ||
self.class.new.help | ||
exit 1 | ||
end | ||
default_task :_invalid_command_call | ||
|
||
def self.exit_on_failure? | ||
true | ||
end | ||
end | ||
end | ||
end |