Class: Lita::CLI

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

Overview

The command line interface for Lita.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.file_path_for(file_name, default_path) ⇒ String

Returns the full destination file path for the given file, using the supplied default_path as the base if run as root, otherwise falling back to the user's home directory.


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

def self.file_path_for(file_name, default_path)
  base_path = Process.euid == 0 ? default_path : ENV["HOME"]
  File.join(base_path, file_name)
end

.source_rootString

Note:

This is a magic method required by Thor for file operations.

The root file path for the templates directory.


15
16
17
# File 'lib/lita/cli.rb', line 15

def self.source_root
  Lita.template_root
end

Instance Method Details

#adapter(name) ⇒ void

This method returns an undefined value.

Generates a new Lita adapter.


92
93
94
# File 'lib/lita/cli.rb', line 92

def adapter(name)
  generate_templates(generate_config(name, "adapter"))
end

#extension(name) ⇒ void

This method returns an undefined value.

Generates a new Lita extension.


108
109
110
# File 'lib/lita/cli.rb', line 108

def extension(name)
  generate_templates(generate_config(name, "extension"))
end

#handler(name) ⇒ void

This method returns an undefined value.

Generates a new Lita handler.


100
101
102
# File 'lib/lita/cli.rb', line 100

def handler(name)
  generate_templates(generate_config(name, "handler"))
end

#new(name = "lita") ⇒ void

This method returns an undefined value.

Generates a new Lita project.


84
85
86
# File 'lib/lita/cli.rb', line 84

def new(name = "lita")
  directory "robot", name
end

#startvoid

This method returns an undefined value.

Starts Lita.


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/lita/cli.rb', line 59

def start
  begin
    Bundler.require
  rescue Bundler::GemfileNotFound
    say I18n.t("lita.cli.no_gemfile_warning"), :red
    abort
  end

  if options[:daemonize]
    say I18n.t("lita.cli.daemon_deprecated"), :red

    Daemon.new(
      options[:pid_file],
      options[:log_file],
      options[:kill]
    ).daemonize
  end

  Lita.run(options[:config])
end

#versionvoid

This method returns an undefined value.

Outputs the current version of Lita.


115
116
117
# File 'lib/lita/cli.rb', line 115

def version
  puts VERSION
end