Class: MPS::CLI::MPS

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cli/mps.rb

Overview

Root Thor dispatcher. All commands self-register via class_eval from lib/mps/cli/commands/*.rb — adding a command means adding a file there.

Constant Summary collapse

VALID_TYPES =
%w[task note log reminder].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


23
# File 'lib/cli/mps.rb', line 23

def self.exit_on_failure? = true

.start(given_args = ARGV, config = {}) ⇒ Object

Intercept bare invocation to honour config’s default_command.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cli/mps.rb', line 26

def self.start(given_args = ARGV, config = {})
  if given_args.empty?
    begin
      conf = ::MPS::Config.load_conf_hash(::MPS::Constants::MPS_CONFIG_FILE)
      default = conf.fetch(:default_command, "open").to_s
      return super(["list"] + given_args, config) if default == "list"
    rescue StandardError
      # Config may not exist yet — fall through to normal start
    end
  end
  super
end

Instance Method Details

#versionObject



42
43
44
# File 'lib/cli/mps.rb', line 42

def version
  say "mps (v#{::MPS::VERSION})"
end