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.

Parameters:

  • file_name (String)

    The name of the file.

  • default_path (String)

    The base of the file path to use when run as root.

Returns:

  • (String)

    The full file path.



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.

Returns:

  • (String)

    The path.



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.

Parameters:

  • name (String)

    The name for the new adapter.



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

def adapter(name)
  config = generate_config(name, "adapter")
  generate_templates(config)
  post_messages(config)
end

#extension(name) ⇒ void

This method returns an undefined value.

Generates a new Lita extension.

Parameters:

  • name (String)

    The name for the new extension.



112
113
114
115
116
# File 'lib/lita/cli.rb', line 112

def extension(name)
  config = generate_config(name, "extension")
  generate_templates(config)
  post_messages(config)
end

#handler(name) ⇒ void

This method returns an undefined value.

Generates a new Lita handler.

Parameters:

  • name (String)

    The name for the new handler.



102
103
104
105
106
# File 'lib/lita/cli.rb', line 102

def handler(name)
  config = generate_config(name, "handler")
  generate_templates(config)
  post_messages(config)
end

#new(name = "lita") ⇒ void

This method returns an undefined value.

Generates a new Lita project.

Parameters:

  • name (String) (defaults to: "lita")

    The directory name for the new 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.



121
122
123
# File 'lib/lita/cli.rb', line 121

def version
  puts VERSION
end