Class: SentinelRb::CLI
- Inherits:
-
Thor
- Object
- Thor
- SentinelRb::CLI
- Defined in:
- lib/sentinel_rb/cli.rb
Overview
Command Line Interface for SentinelRb
Instance Method Summary collapse
Instance Method Details
#analyze ⇒ Object
21 22 23 24 25 26 27 28 29 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 |
# File 'lib/sentinel_rb/cli.rb', line 21 def analyze # Load configuration config = load_config([:config]) analyzer = SentinelRb::Analyzer.new(config) # Determine files to analyze files_to_analyze = determine_files() error_exit("No files found to analyze. Use --glob or --files to specify files.") if files_to_analyze.empty? say("Analyzing #{files_to_analyze.length} files...") unless [:quiet] # Run analysis results = files_to_analyze.map do |file| say(" Analyzing #{file}...") if [:verbose] analyzer.analyze_file(file, analyzer_ids: [:analyzers]) end # Format and output results formatted_output = SentinelRb::Report::Formatter.format( results, format: [:format], show_summary: ![:no_summary], colorize: ![:no_color] && $stdout.tty? ) output_results(formatted_output, [:output]) # Exit with appropriate code summary = analyzer.summarize_results(results) exit_code = summary[:total_findings].positive? ? 1 : 0 exit(exit_code) rescue StandardError => e error_exit("Analysis failed: #{e.}") end |
#config ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/sentinel_rb/cli.rb', line 63 def config config = load_config([:config]) say("Configuration loaded from: #{[:config]}") say("") config.to_h.each do |key, value| say("#{key}: #{value}") end end |
#test_connection ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sentinel_rb/cli.rb', line 75 def test_connection config = load_config([:config]) client = SentinelRb::Client::Factory.create(config) say("Testing connection to #{config.provider}...") begin # Test with a simple analysis result = client.analyze_content("This is a test prompt for connection verification.") if result[:relevance_score] say("✅ Connection successful!") say("Test analysis score: #{result[:relevance_score].round(3)}") else error_exit("❌ Connection failed: No response received") end rescue StandardError => e error_exit("❌ Connection failed: #{e.}") end end |
#version ⇒ Object
57 58 59 |
# File 'lib/sentinel_rb/cli.rb', line 57 def version say("SentinelRb #{SentinelRb::VERSION}") end |