Class: Kotoshu::CheckCommand
- Inherits:
-
Thor
- Object
- Thor
- Kotoshu::CheckCommand
- Defined in:
- lib/kotoshu/commands/check_command.rb
Instance Method Summary collapse
Instance Method Details
#check(file) ⇒ Object
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 |
# File 'lib/kotoshu/commands/check_command.rb', line 31 def check(file) # Validate file exists unless File.exist?(file) puts "Error: File not found: #{file}" exit 1 end # Detect language if auto language = detect_language(file, [:language]) # Load document document = load_document(file, language) # Load analyzer based on model type analyzer = load_analyzer(language, [:model]) puts "Analyzing #{file} (language: #{language})..." if [:verbose] # Run interactive or batch mode if [:interactive] run_interactive_mode(document, analyzer) else run_batch_mode(document, analyzer) end end |
#stdin ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/kotoshu/commands/check_command.rb', line 85 def stdin text = $stdin.read if text.nil? || text.empty? puts "Error: No input provided" exit 1 end # Delegate to string command invoke :string, [text], end |
#string(text) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/kotoshu/commands/check_command.rb', line 60 def string(text) language_code = [:language] # Create document from string format_sym = [:format].to_sym document = Documents::Document.from_string(text, language_code: language_code) # Load analyzer analyzer = load_analyzer(language_code, [:model]) puts "Analyzing..." if [:verbose] # Always use batch mode for string input reporter = run_batch_mode(document, analyzer) # Print report reporter.print(format: [:format].to_sym) # Exit with appropriate code exit reporter.exit_code end |