Class: Airb::Tools::FS::ListFiles

Inherits:
VSM::ToolCapsule
  • Object
show all
Defined in:
lib/airb/tools/fs/list_files.rb

Instance Method Summary collapse

Instance Method Details

#run(args) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/airb/tools/fs/list_files.rb', line 14

def run(args)
  path = args["path"].to_s.empty? ? "." : args["path"]
  root = governance.send(:safe_path, path) rescue Dir.pwd
  entries = Dir.children(root).sort.map do |e|
    full = File.join(root, e)
    File.directory?(full) ? "#{e}/" : e
  end
  entries.join("\n")
end