Class: Shellfie::CLI
- Inherits:
-
Object
- Object
- Shellfie::CLI
- Includes:
- CLIAuthoring, CLIGenerate, CLIInfo, CLIRun
- Defined in:
- lib/shellfie/cli.rb
Constant Summary collapse
- COMMANDS =
%w[generate run record replay new format compile schema completion watch init themes validate inspect doctor version help].freeze
Constants included from CLIGenerate
Shellfie::CLIGenerate::ANIMATED_FORMATS, Shellfie::CLIGenerate::ASPECT_PRESETS, Shellfie::CLIGenerate::SEMANTIC_FORMATS, Shellfie::CLIGenerate::STATIC_FORMATS, Shellfie::CLIGenerate::SUPPORTED_FORMATS
Instance Method Summary collapse
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ CLI
Returns a new instance of CLI.
21 22 23 24 |
# File 'lib/shellfie/cli.rb', line 21 def initialize(args) @args = args.dup @options = {} end |
Instance Method Details
#run ⇒ Object
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/shellfie/cli.rb', line 26 def run return show_help if @args.empty? command = @args.shift case command when "generate", "g" run_generate when "init" run_init when "run" run_session when "record" run_session(record: true) when "replay" replay_session when "new" run_new when "format" run_format when "compile" run_compile when "schema" run_schema when "completion" run_completion when "watch" run_watch when "themes" run_themes when "validate" run_validate when "inspect" run_inspect when "doctor" run_doctor when "version", "-v", "--version" run_version when "help", "-h", "--help" show_help else warn_error "Unknown command: #{command}" warn_error "Run 'shellfie help' for usage information." exit 1 end rescue Shellfie::Error => e if @options[:validation_format] && @options[:validation_format] != "text" emit_validation_report(valid: false, error: e) else warn_error "Error: #{e.}" end exit determine_exit_code(e) rescue OptionParser::ParseError => e warn_error "Error: #{e.}" exit 1 rescue SystemCallError => e warn_error "Error: #{e.}" exit 5 end |