Class: Lita::CLI
Overview
The command line interface for Lita.
Class Method Summary collapse
-
.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. -
.source_root ⇒ String
The root file path for the templates directory.
Instance Method Summary collapse
-
#adapter(name) ⇒ void
Generates a new Lita adapter.
-
#extension(name) ⇒ void
Generates a new Lita extension.
-
#handler(name) ⇒ void
Generates a new Lita handler.
-
#new(name = "lita") ⇒ void
Generates a new Lita project.
-
#start ⇒ void
Starts Lita.
-
#version ⇒ void
Outputs the current version of Lita.
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_root ⇒ String
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 95 96 |
# File 'lib/lita/cli.rb', line 92 def adapter(name) config = generate_config(name, "adapter") generate_templates(config) (config) end |
#extension(name) ⇒ void
This method returns an undefined value.
Generates a new Lita extension.
112 113 114 115 116 |
# File 'lib/lita/cli.rb', line 112 def extension(name) config = generate_config(name, "extension") generate_templates(config) (config) end |
#handler(name) ⇒ void
This method returns an undefined value.
Generates a new Lita handler.
102 103 104 105 106 |
# File 'lib/lita/cli.rb', line 102 def handler(name) config = generate_config(name, "handler") generate_templates(config) (config) 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 |
#start ⇒ void
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 [:daemonize] say I18n.t("lita.cli.daemon_deprecated"), :red Daemon.new( [:pid_file], [:log_file], [:kill] ).daemonize end Lita.run([:config]) end |
#version ⇒ void
This method returns an undefined value.
Outputs the current version of Lita.
121 122 123 |
# File 'lib/lita/cli.rb', line 121 def version puts VERSION end |