Class: Xnlogic::CLI

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

Defined Under Namespace

Classes: Application

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



14
15
16
17
18
19
20
21
22
# File 'lib/xnlogic/cli.rb', line 14

def initialize(*args)
  super
rescue UnknownArgumentError => e
  raise InvalidOption, e.message
ensure
  self.options ||= {}
  Xnlogic.ui = UI::Shell.new(options)
  Xnlogic.ui.level = "debug" if options["verbose"]
end

Class Method Details

.handle_no_command_error(command, has_namespace = $thor_runner) ⇒ Object



51
52
53
54
# File 'lib/xnlogic/cli.rb', line 51

def self.handle_no_command_error(command, has_namespace = $thor_runner)
  return super unless command_path = Xnlogic.which("xnlogic-#{command}")
  Kernel.exec(command_path, *ARGV[1..-1])
end

.source_rootObject



70
71
72
# File 'lib/xnlogic/cli.rb', line 70

def self.source_root
  File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end

.startObject



7
8
9
10
11
12
# File 'lib/xnlogic/cli.rb', line 7

def self.start(*)
  super
rescue Exception => e
  Xnlogic.ui = UI::Shell.new
  raise e
end

Instance Method Details

#application(name) ⇒ Object



65
66
67
68
# File 'lib/xnlogic/cli.rb', line 65

def application(name)
  require 'xnlogic/cli/application'
  Application.new(options, name, self).run
end

#help(cli = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xnlogic/cli.rb', line 33

def help(cli = nil)
  case cli
  when nil       then command = "xnlogic"
  else                command = "xnlogic-#{cli}"
  end
  manpages = %w(xnlogic)
  if manpages.include?(command)
    root = File.expand_path("../man", __FILE__)
    if Xnlogic.which("man") && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
      Kernel.exec "man #{root}/#{command}"
    else
      puts File.read("#{root}/#{command}.txt")
    end
  else
    super
  end
end