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)


22
23
24
# File 'lib/gemstash/cli.rb', line 22

def self.exit_on_failure?
  true
end

.start(args = ARGV) ⇒ Object



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

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



56
57
58
# File 'lib/gemstash/cli.rb', line 56

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

#help(command = nil) ⇒ Object



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

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



67
68
69
# File 'lib/gemstash/cli.rb', line 67

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

#startObject



76
77
78
# File 'lib/gemstash/cli.rb', line 76

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

#statusObject



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

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

#stopObject



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

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

#versionObject



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

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