class Ore::CLI

Public Instance Methods

install(uri) click to toggle source

Installs a template into ‘~/.ore/templates`.

@param [String] uri

The Git URI to install the template from.
# 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() click to toggle source

Lists builtin and installed templates.

# 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) click to toggle source

Removes a previously installed template.

@param [String] name

The name of the template to remove.
# 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() click to toggle source

Updates all previously installed templates.

# 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
version() click to toggle source

Prints {Ore::VERSION}.

# File lib/ore/cli.rb, line 99
def version
  puts "ore #{Ore::VERSION}"
end