Class: MontyAI::CLI
- Inherits:
-
Thor
- Object
- Thor
- MontyAI::CLI
- Defined in:
- lib/monty_ai/cli.rb
Instance Method Summary collapse
Instance Method Details
#explain(file = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/monty_ai/cli.rb', line 8 def explain(file = nil) if file.nil? && !$stdin.tty? # Handle piped input code = $stdin.read handle_code(code) elsif file.nil? # No file provided and no pipe puts "Error: Please provide a file to explain or pipe code to the command." exit 1 else # Handle file input begin code = FileHandler.read(file) handle_code(code, file) rescue Error => e puts "Error: #{e.}" exit 1 end end end |