Class: Fixi::Command::Add
- Inherits:
-
Object
- Object
- Fixi::Command::Add
- Defined in:
- lib/fixi/command/add.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.arghelp ⇒ Object
9 10 11 |
# File 'lib/fixi/command/add.rb', line 9 def self.arghelp "[<dir>|<file>]" end |
.details ⇒ Object
13 14 15 |
# File 'lib/fixi/command/add.rb', line 13 def self.details "If no argument is given, the current directory ('.') is assumed." end |
.synopsis ⇒ Object
5 6 7 |
# File 'lib/fixi/command/add.rb', line 5 def self.synopsis "Add new files to the index" end |
Instance Method Details
#execute(args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fixi/command/add.rb', line 17 def execute args opts = Trollop:: args do Fixi::Command. "add" 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.(args[0] || ".") index = Fixi::Index.new(path) index.find(path) do |abspath| relpath = index.relpath(abspath) unless index.contains?(relpath) puts "A #{opts[:absolute] ? abspath : relpath}" index.add(relpath) unless opts[:dry_run] end end end |