added a customize command to generate a template in the home directory
This commit is contained in:
parent
a341390510
commit
57157b5c6b
14
bin/qw
14
bin/qw
@ -33,8 +33,18 @@ opts = OptionParser.new do |opts|
|
||||
exit(0)
|
||||
end
|
||||
|
||||
opts.on("--customize", "Create files for customizing Qwandry") do
|
||||
|
||||
opts.on("--customize", "Create and edit files for customizing Qwandry") do
|
||||
dir = ENV['HOME'] && ENV['HOME'] + '/.qwandry/'
|
||||
if !dir
|
||||
puts "Home directory must be defined."
|
||||
exit(1)
|
||||
else
|
||||
FileUtils.mkdir(dir, :verbose=>true) unless File.exist?(dir)
|
||||
Dir[File.dirname(__FILE__) + '/../templates/*'].each do |path|
|
||||
FileUtils.cp(path, dir, :verbose=>true, :preserve=>true)
|
||||
end
|
||||
@qwandry.launch dir
|
||||
end
|
||||
exit(0)
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'optparse'
|
||||
require 'set'
|
||||
require 'fileutils'
|
||||
|
||||
# Informal Spec:
|
||||
#
|
||||
|
@ -49,10 +49,12 @@ module Qwandry
|
||||
packages
|
||||
end
|
||||
|
||||
# Launches a `package`. Unless `editor` will check against the environment by default.
|
||||
# Launches a Package or path represented by a String. Unless `editor` will
|
||||
# check against the environment by default.
|
||||
def launch(package, editor=nil)
|
||||
editor ||= @editor || ENV['VISUAL'] || ENV['EDITOR']
|
||||
system editor, *package.paths
|
||||
paths = package.is_a?(String) ? [package] : package.paths
|
||||
system editor, *paths
|
||||
end
|
||||
|
||||
private
|
||||
|
Loading…
Reference in New Issue
Block a user