Skip to content

Commit

Permalink
add templates command and documentation for template-related commands
Browse files Browse the repository at this point in the history
  • Loading branch information
davejacobs committed Aug 28, 2012
1 parent 3b1350d commit 302fbdb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/mint
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ when :uninstall
# TODO: Clean up syntax for this to match install syntax
# Right now it's `mint install file.scss -t pro` vs. `mint uninstall pro`
Mint::CommandLine.uninstall(ARGV.shift, commandline_options)
when :templates
Mint::CommandLine.templates
when :edit
Mint::CommandLine.edit(ARGV.shift, commandline_options)
when :set
Expand Down
2 changes: 2 additions & 0 deletions features/install.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ Feature: Publish document with varying options at the command line
Scenario: Uninstall an installed file
When I run `mint install -t pro file.sass`
Then a directory named ".mint/templates/pro" should exist
When I run `mint templates`
Then the output should contain "pro"
When I run `mint uninstall pro`
Then a directory named ".mint/templates/pro" should not exist
18 changes: 18 additions & 0 deletions lib/mint/commandline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def self.help(message)
puts message
end

# Install the named file as a template
#
# @param [File] file the file to install to the appropriate Mint directory
# @param [Hash] commandline_options a structured set of options, including
# a scope label that the method will use to choose the appropriate
Expand All @@ -117,6 +119,13 @@ def self.install(file, commandline_options={})
end
end

# Uninstall the named template
#
# @param [String] name the name of the template to be uninstalled
# @param [Hash] commandline_options a structured set of options, including
# a scope label that the method will use to choose the appropriate
# installation directory
# @return [void]
def self.uninstall(name, commandline_options={})
scope = [:global, :user].
select {|e| commandline_options[e] }.
Expand All @@ -125,6 +134,15 @@ def self.uninstall(name, commandline_options={})
FileUtils.rm_r Mint.template_path(name, :all, :scope => scope)
end

# List the installed templates
#
# @return [void]
def self.templates
Mint.templates.each do |template|
puts "#{File.basename template} [#{template}]"
end
end

# Retrieve named template file (probably a built-in or installed
# template) and shell out that file to the user's favorite editor.
#
Expand Down

0 comments on commit 302fbdb

Please sign in to comment.