Class: LlmsTxt::CLI
- Inherits:
-
Object
- Object
- LlmsTxt::CLI
- Defined in:
- lib/llms_txt/cli.rb
Overview
Command-line interface for llms-txt gem
Provides commands for generating, transforming, parsing, and validating llms.txt files. All file paths must be specified using flags (-d/–docs) for consistency.
Class Method Summary collapse
-
.run(argv = ARGV) ⇒ Object
Run the CLI with given arguments.
Instance Method Summary collapse
-
#run(argv) ⇒ Object
Execute CLI command with error handling.
Class Method Details
.run(argv = ARGV) ⇒ Object
Run the CLI with given arguments
19 20 21 |
# File 'lib/llms_txt/cli.rb', line 19 def self.run(argv = ARGV) new.run(argv) end |
Instance Method Details
#run(argv) ⇒ Object
Execute CLI command with error handling
Parses command-line arguments and delegates to appropriate command handler. Handles all LlmsTxt errors gracefully with user-friendly messages.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/llms_txt/cli.rb', line 30 def run(argv) = (argv) case [:command] when 'generate', nil generate() when 'transform' transform() when 'bulk-transform' bulk_transform() when 'parse' parse() when 'validate' validate() when 'version' show_version else puts "Unknown command: #{options[:command]}" puts "Run 'llms-txt --help' for usage information" exit 1 end rescue LlmsTxt::Errors::BaseError => e puts "Error: #{e.message}" exit 1 rescue StandardError => e puts "Unexpected error: #{e.message}" puts e.backtrace.join("\n") if &.fetch(:verbose, false) exit 1 end |