Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

Commit

Permalink
Adds "prefix" option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jairtrejo committed Apr 22, 2012
1 parent 2f3a1cf commit 5ec3c75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Usage: effuse [OPTION...] [DEST]
-y, --noconfirm CHOICE Assume CHOICE on file conflicts
-n, --no-backup Do not create backup files
-p --prefix PREFIX Prefix relative paths with PREFIX
-v, --verbose Show verbose output
-h, --help Show this message
```
Expand Down
10 changes: 9 additions & 1 deletion bin/effuse
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ options = OpenStruct.new(:verbose => false,
:clean => false,
:noconfirm => nil,
:backup => true,
:prefix => "",
:exclude => %w[.effuseignore .git .gitignore .gitmodules *~ .*~ .*.swp])

if File.exist?('.effuseignore')
Expand Down Expand Up @@ -45,6 +46,12 @@ OptionParser.new do |o|

o.separator ''

o.on('-p', '--prefix PREFIX', 'Prefix relative paths with PREFIX') do |prefix|
options.prefix = prefix
end

o.separator ''

o.on('-v', '--verbose', 'Show verbose output') do
options.verbose = true
end
Expand Down Expand Up @@ -84,7 +91,8 @@ dirs.each do |dir|
end

puts "found #{file}" if options.verbose
dest = File.join([dest_dir] + file.split('/')[1..-1])
relpath = file.split('/')[1..-1]
dest = File.join([dest_dir, options.prefix + relpath[0]] + relpath[1..-1])
files[File.expand_path(file)] = dest # Shakes fist at Ruby 1.8 (File.absolute_path)
end
end
Expand Down

0 comments on commit 5ec3c75

Please sign in to comment.