18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fixi/command/rm.rb', line 18
def execute args
opts = Trollop::options args do
banner Fixi::Command.banner "rm"
opt :absolute, "Show absolute paths. By default, paths are reported
relative to the index root.".pack
opt :dry_run, "Don't do anything; just report what would be done"
end
path = File.expand_path(args[0] || ".")
index = Fixi::Index.new(path)
index.each(args[0]) do |hash|
relpath = hash['relpath']
abspath = index.rootpath + '/' + relpath
if index.file_in_scope(relpath)
unless File.exists?(abspath)
puts "D #{opts[:absolute] ? abspath : relpath}"
index.delete relpath unless opts[:dry_run]
end
else
puts "X #{opts[:absolute] ? abspath : relpath}"
index.delete relpath unless opts[:dry_run]
end
end
end
|