Class: Clian::Cli
- Inherits:
-
Thor
- Object
- Thor
- Clian::Cli
- Defined in:
- lib/clian/cli.rb
Constant Summary collapse
- DEFAULT_CONFIG_HOME =
config files
File.join((ENV["XDG_CONFIG_HOME"] || "~/.config"), basename)
- DEFAULT_CONFIG_FILE =
"config.yml"
- DEFAULT_CONFIG_PATH =
File.join(DEFAULT_CONFIG_HOME, DEFAULT_CONFIG_FILE)
- NAMED_OPTIONS =
{}
Class Method Summary collapse
-
.bundler_rbenv_setup(command_path) ⇒ Object
rbenv support: If this file is a symlink, and bound to a specific ruby version via rbenv (indicated by RBENV_VERSION), I want to resolve the symlink and re-exec the original executable respecting the .ruby_version which should indicate the right version.
- .default_config_home ⇒ Object
- .default_config_path ⇒ Object
- .expand_class_option(*names) ⇒ Object
- .expand_option(*names) ⇒ Object
-
.named_option(name, options) ⇒ Object
register preset options.
Instance Method Summary collapse
- #completions(*command) ⇒ Object
- #configuration(name = nil) ⇒ Object
- #help(command = nil) ⇒ Object
- #version ⇒ Object
Class Method Details
.bundler_rbenv_setup(command_path) ⇒ Object
rbenv support: If this file is a symlink, and bound to a specific ruby version via rbenv (indicated by RBENV_VERSION), I want to resolve the symlink and re-exec the original executable respecting the .ruby_version which should indicate the right version.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clian/cli.rb', line 25 def self.bundler_rbenv_setup(command_path) if File.symlink?(command_path) and ENV["RBENV_VERSION"] ENV["RBENV_VERSION"] = nil shims_path = File.("shims", ENV["RBENV_ROOT"]) ENV["PATH"] = shims_path + ":" + ENV["PATH"] exec(File.readlink(command_path), *ARGV) end gemfile = File.("../../Gemfile", command_path) if File.exists?(gemfile + ".lock") ENV["BUNDLE_GEMFILE"] = gemfile require "bundler/setup" end end |
.default_config_home ⇒ Object
14 |
# File 'lib/clian/cli.rb', line 14 def self.default_config_home ; DEFAULT_CONFIG_HOME; end |
.default_config_path ⇒ Object
15 |
# File 'lib/clian/cli.rb', line 15 def self.default_config_path ; DEFAULT_CONFIG_PATH; end |
.expand_class_option(*names) ⇒ Object
52 53 54 |
# File 'lib/clian/cli.rb', line 52 def self.(*names) (:class, *names) end |
.expand_option(*names) ⇒ Object
48 49 50 |
# File 'lib/clian/cli.rb', line 48 def self.(*names) (:method, *names) end |
.named_option(name, options) ⇒ Object
register preset options
44 45 46 |
# File 'lib/clian/cli.rb', line 44 def self.named_option(name, ) ::Clian::Cli::NAMED_OPTIONS[name] = end |
Instance Method Details
#completions(*command) ⇒ Object
114 115 116 117 118 |
# File 'lib/clian/cli.rb', line 114 def completions(*command) help = self.class.commands = self.class. Clian::Command::Completions.new(help, , command, config) end |
#configuration(name = nil) ⇒ Object
125 126 127 |
# File 'lib/clian/cli.rb', line 125 def configuration(name = nil) puts Clian::Converter::Emacs.new.to_emacs(config.get_value(name)) end |
#help(command = nil) ⇒ Object
89 90 91 |
# File 'lib/clian/cli.rb', line 89 def help(command = nil) super(command) end |