Class: Clian::Cli
- Inherits:
-
Thor
- Object
- Thor
- Clian::Cli
- Defined in:
- lib/clian/cli.rb
Constant Summary collapse
- CONFIG_HOME =
config files
File.join((ENV["XDG_CONFIG_HOME"] || "~/.config"), basename)
- CONFIG_FILE =
"config.yml"
- CONFIG_PATH =
File.join(CONFIG_HOME, 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.
- .config_home ⇒ Object
- .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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/clian/cli.rb', line 24 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(__FILE__), *ARGV) end gemfile = File.("../../Gemfile", command_path) if File.exists?(gemfile + ".lock") ENV["BUNDLE_GEMFILE"] = gemfile require "bundler/setup" end end |
.config_home ⇒ Object
13 |
# File 'lib/clian/cli.rb', line 13 def self.config_home ; CONFIG_HOME; end |
.config_path ⇒ Object
14 |
# File 'lib/clian/cli.rb', line 14 def self.config_path ; CONFIG_PATH; end |
.expand_class_option(*names) ⇒ Object
51 52 53 |
# File 'lib/clian/cli.rb', line 51 def self.(*names) (:class, *names) end |
.expand_option(*names) ⇒ Object
47 48 49 |
# File 'lib/clian/cli.rb', line 47 def self.(*names) (:method, *names) end |
.named_option(name, options) ⇒ Object
register preset options
43 44 45 |
# File 'lib/clian/cli.rb', line 43 def self.named_option(name, ) ::Clian::Cli::NAMED_OPTIONS[name] = end |
Instance Method Details
#completions(*command) ⇒ Object
113 114 115 116 117 |
# File 'lib/clian/cli.rb', line 113 def completions(*command) help = self.class.commands = self.class. Clian::Command::Completions.new(help, , command, config) end |
#configuration(name = nil) ⇒ Object
124 125 126 |
# File 'lib/clian/cli.rb', line 124 def configuration(name = nil) puts Clian::Converter::Emacs.new.to_emacs(config.get_value(name)) end |
#help(command = nil) ⇒ Object
88 89 90 |
# File 'lib/clian/cli.rb', line 88 def help(command = nil) super(command) end |