diff --git a/bin/qw b/bin/qw index 6813fa4..d341e60 100755 --- a/bin/qw +++ b/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 diff --git a/lib/qwandry.rb b/lib/qwandry.rb index 19e795b..7108127 100644 --- a/lib/qwandry.rb +++ b/lib/qwandry.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'optparse' require 'set' +require 'fileutils' # Informal Spec: # diff --git a/lib/qwandry/launcher.rb b/lib/qwandry/launcher.rb index 93b32a7..989e65d 100644 --- a/lib/qwandry/launcher.rb +++ b/lib/qwandry/launcher.rb @@ -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