Class: Ore::CLI
- Inherits:
-
Thor
- Object
- Thor
- Ore::CLI
- Defined in:
- lib/ore/cli.rb
Instance Method Summary collapse
-
#install(uri) ⇒ Object
Installs a template into
~/.ore/templates
. -
#list ⇒ Object
Lists builtin and installed templates.
-
#remove(name) ⇒ Object
Removes a previously installed template.
-
#update ⇒ Object
Updates all previously installed templates.
-
#version ⇒ Object
Prints VERSION.
Instance Method Details
#install(uri) ⇒ Object
Installs a template into ~/.ore/templates
.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ore/cli.rb', line 44 def install(uri) url = URI(uri) name = File.basename(url.path) name.gsub!(/\.git$/,'') path = File.join(Config::TEMPLATES_DIR,name) if File.directory?(path) say "Template #{name} already installed.", :red exit -1 end FileUtils.mkdir_p(path) system('git','clone',uri,path) end |
#list ⇒ Object
Lists builtin and installed templates.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ore/cli.rb', line 24 def list print_template = lambda { |path| puts " #{File.basename(path)}" } say "Builtin templates:", :green Config.builtin_templates(&print_template) say "Installed templates:", :green Config.installed_templates(&print_template) end |
#remove(name) ⇒ Object
Removes a previously installed template.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ore/cli.rb', line 82 def remove(name) name = File.basename(name) path = File.join(Config::TEMPLATES_DIR,name) unless File.exists?(path) say "Unknown template: #{name}", :red exit -1 end FileUtils.rm_rf(path) end |
#update ⇒ Object
Updates all previously installed templates.
66 67 68 69 70 71 72 |
# File 'lib/ore/cli.rb', line 66 def update Config.installed_templates do |path| say "Updating #{File.basename(path)} ...", :green Dir.chdir(path) { system('git','pull','-q') } end end |