Class: LLM::Shell::Command::DirImport

Inherits:
LLM::Shell::Command show all
Defined in:
lib/llm/shell/commands/dir_import.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LLM::Shell::Command

builtin?, description, enabled?, inherited, #initialize, name

Constructor Details

This class inherits a constructor from LLM::Shell::Command

Class Method Details

.complete(path) ⇒ Array<String>

Completes a path with a wildcard.

Parameters:

  • path (String)

    The path to complete.

Returns:

  • (Array<String>)

    Returns the completed path(s)



14
15
16
# File 'lib/llm/shell/commands/dir_import.rb', line 14

def self.complete(path)
  Dir["#{path}*"]
end

Instance Method Details

#call(dir) ⇒ void

This method returns an undefined value.

Recursively imports all files in a directory.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/llm/shell/commands/dir_import.rb', line 21

def call(dir)
  Dir.entries(dir).each do |file|
    if file == "." || file == ".."
      next
    elsif File.directory? File.join(dir, file)
      call File.join(dir, file)
    else
      import File.join(dir, file)
    end
  end
end