Class: Gemstash::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gemstash/cli.rb,
lib/gemstash/cli/base.rb,
lib/gemstash/cli/stop.rb,
lib/gemstash/cli/setup.rb,
lib/gemstash/cli/start.rb,
lib/gemstash/cli/status.rb,
lib/gemstash/cli/authorize.rb

Overview

Base Command Line Interface class.

Defined Under Namespace

Classes: Authorize, Base, Error, Setup, Start, Status, Stop

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gemstash/cli.rb', line 24

def self.exit_on_failure?
  true
end

.start(args = ARGV) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/gemstash/cli.rb', line 28

def self.start(args = ARGV)
  help_flags = %w[-h --help]

  if args.any? {|a| help_flags.include?(a) }
    super(%w[help] + args.reject {|a| help_flags.include?(a) })
  else
    super
  end
end

Instance Method Details

#authorize(*args) ⇒ Object



62
63
64
# File 'lib/gemstash/cli.rb', line 62

def authorize(*args)
  Gemstash::CLI::Authorize.new(self, *args).run
end

#help(command = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gemstash/cli.rb', line 38

def help(command = nil)
  command ||= "readme"
  page = manpage(command)

  if page && which("man")
    exec "man", page
  elsif page
    puts File.read("#{page}.txt")
  else
    super
  end
end

#setupObject



73
74
75
# File 'lib/gemstash/cli.rb', line 73

def setup
  Gemstash::CLI::Setup.new(self).run
end

#startObject



82
83
84
# File 'lib/gemstash/cli.rb', line 82

def start
  Gemstash::CLI::Start.new(self).run
end

#statusObject



89
90
91
# File 'lib/gemstash/cli.rb', line 89

def status
  Gemstash::CLI::Status.new(self).run
end

#stopObject



96
97
98
# File 'lib/gemstash/cli.rb', line 96

def stop
  Gemstash::CLI::Stop.new(self).run
end

#versionObject



101
102
103
# File 'lib/gemstash/cli.rb', line 101

def version
  say "Gemstash version #{Gemstash::VERSION}"
end