Class: Ace::Docs::CLI::Commands::Discover

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
ScopeOptions, Support::Cli::Base
Defined in:
lib/ace/docs/cli/commands/discover.rb

Overview

ace-support-cli Command class for the discover command

This wraps the discover logic in a ace-support-cli compatible interface.

Constant Summary collapse

EXIT_SUCCESS =

Exit codes

0
EXIT_ERROR =
1

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ace/docs/cli/commands/discover.rb', line 48

def call(**options)
  scope_globs = normalized_scope_globs(options, project_root: options[:project_root])
  registry = Ace::Docs::Organisms::DocumentRegistry.new(
    project_root: options[:project_root],
    scope_globs: scope_globs
  )
  documents = registry.all

  if documents.empty?
    puts "No managed documents found."
    return EXIT_SUCCESS
  end

  puts "Found #{documents.size} managed documents:"
  documents.each do |doc|
    puts "  #{doc.relative_path || doc.path} (#{doc.doc_type})"
  end
  EXIT_SUCCESS
rescue => e
  warn "Error discovering documents: #{e.message}"
  warn e.backtrace.join("\n  ") if debug?(options)
  EXIT_ERROR
end