lib/aia/main.rb in aia-0.3.19 vs lib/aia/main.rb in aia-0.3.20
- old
+ new
@@ -18,13 +18,14 @@
def initialize(args= ARGV)
AIA::Cli.new(args)
@logger = AIA::Logging.new(AIA.config.log_file)
- @tools = AIA::Tools.new
+ AIA::Tools.load_tools
- tools.class.verify_tools
+ # TODO: still should verify that the tools are ion the $PATH
+ # tools.class.verify_tools
end
def call
get_prompt
@@ -35,17 +36,33 @@
# TODO: the context_files left in the @arguments array
# should be verified BEFORE asking the user for a
# prompt keyword or process the prompt. Do not
# want invalid files to make it this far.
+ found = AIA::Tools
+ .search_for(
+ name: AIA.config.backend,
+ role: :backend
+ )
- mods = AIA::Mods.new(
- extra_options: AIA.config.extra,
+ if found.empty?
+ abort "There are no :backend tools named #{AIA.config.backend}"
+ end
+
+ if found.size > 1
+ abort "There are #{found.size} :backend tools with the name #{AIAA.config.backend}"
+ end
+
+ backend_klass = found.first.klass
+
+ abort "backend not found: #{AIA.config.backend}" if backend_klass.nil?
+
+ backend = backend_klass.new(
text: @prompt.to_s,
files: AIA.config.arguments # FIXME: want validated context files
)
- result = mods.run
+ result = backend.run
AIA.config.output_file.write result
logger.prompt_result(@prompt, result)
end