Class: Zephira::Completions::FileNames
- Inherits:
-
Object
- Object
- Zephira::Completions::FileNames
- Defined in:
- lib/zephira/completions/file_names.rb
Class Method Summary collapse
Class Method Details
.complete(input:, agent:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/zephira/completions/file_names.rb', line 6 def self.complete(input:, agent:) return [] unless input.start_with?("@") prefix = input[1..] pattern = if prefix.include?("/") prefix.end_with?("/") ? "#{prefix}*" : File.join(File.dirname(prefix), "#{File.basename(prefix)}*") else "#{prefix}*" end Dir.glob(pattern).map do |path| "@#{path}#{File.directory?(path) ? "/" : ""}" end end |