Class: Amaterasu::CLI
- Inherits:
-
Object
- Object
- Amaterasu::CLI
- Defined in:
- lib/amaterasu/cli.rb
Overview
Handles arguments parsing when launching the emulator.
Class Method Summary collapse
Class Method Details
.parse(arguments) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 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 55 56 57 58 |
# File 'lib/amaterasu/cli.rb', line 8 def self.parse(arguments) # @type var options: emulator_options = { audio: nil, cycles: nil, profiling: nil, steps: nil, trace: nil, video: nil, rom_path: nil } opt_parser = OptionParser.new do |parser| parser. = 'Usage: amaterasu [options] ROM_PATH' parser.on('-a', '--audio=AUDIO', 'Define the audio backend') do |audio| [:audio] = audio end parser.on('-c', '--cycles=n', Integer, 'Amount of dots to tick') do |n| [:cycles] = n end parser.on( '-p', '--profiling=MODE', %w[cpu object wall], 'Enable Stackprof profiling (cpu, object, wall)' ) do |mode| [:profiling] = mode.to_sym end parser.on('-s', '--steps=n', Integer, 'Amount of CPU steps to run') do |n| [:steps] = n end parser.on('-t', '--trace=COMPONENT', 'Enable logging for specific component') do |component| [:trace] = component end parser.on('-v', '--video=VIDEO', 'Define the video backend') do |video| [:video] = video end end opt_parser.parse!(arguments) [:rom_path] = arguments.first raise ArgumentError, 'ROM_PATH must be provided' unless [:rom_path] end |