Class: ModuleSync::CLI::Thor

Inherits:
Thor
  • Object
show all
Defined in:
lib/modulesync/cli/thor.rb

Overview

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

  • show subcommands help using ‘msync subcommand –help`

Direct Known Subclasses

Base, Hook

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/modulesync/cli/thor.rb', line 33

def self.exit_on_failure?
  true
end

.start(*args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/modulesync/cli/thor.rb', line 15

def self.start(*args)
  if (Thor::HELP_MAPPINGS & ARGV).any? && subcommands.none? { |command| command.start_with?(ARGV[0]) }
    Thor::HELP_MAPPINGS.each do |cmd|
      if (match = ARGV.delete(cmd))
        ARGV.unshift match
      end
    end
  end
  super
end

Instance Method Details

#_invalid_command_callObject



27
28
29
30
# File 'lib/modulesync/cli/thor.rb', line 27

def _invalid_command_call
  self.class.new.help
  exit 1
end