Class: Opal::CLIOptions
- Defined in:
- opal/lib/opal/cli_options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ CLIOptions
constructor
A new instance of CLIOptions.
Constructor Details
#initialize ⇒ CLIOptions
Returns a new instance of CLIOptions
5 6 7 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 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 85 86 87 88 89 90 91 92 93 |
# File 'opal/lib/opal/cli_options.rb', line 5 def initialize @options = {} super do |opts| opts. = 'Usage: opal [options] -- [programfile]' opts.on('-v', '--version', 'Display Opal Version') do |v| require 'opal/version' puts "Opal v#{Opal::VERSION}" exit end opts.on("-h", "--help", "Show this message") do puts opts exit end opts.separator '' opts.separator 'Basic Options:' opts.on('-I', '--include DIR', 'Append a load path (may be used more than once)') do |i| [:load_paths] ||= [] [:load_paths] << i end opts.on('-e', '--eval SOURCE', String, 'One line of script. Several -e\'s allowed. Omit [programfile]') do |source| [:evals] ||= [] [:evals] << source end opts.on('-r', '--require LIBRARY', String, 'Require the library before executing your script') do |library| [:requires] ||= [] [:requires] << library end opts.on('-s', '--sexp', 'Show Sexps') do [:sexp] = true end opts.on('-m', '--map', 'Show sourcemap') do [:map] = true end opts.on('-c', '--compile', 'Compile to JavaScript') do [:compile] = true end opts.on('-s', '--server [PORT]', 'Start a server (default port: 3000)') do |port| [:server] = port.to_i end opts.separator '' opts.separator 'Compilation Options:' opts.on('-M', '--[no-]method-missing', 'Disable method missing') do |val| [:method_missing] = val end opts.on('-A', '--[no-]arity-check', 'Enable arity check') do |value| [:arity_check] = value end opts.on('-C', '--[no-]const-missing', 'Disable const missing') do |value| [:const_missing] = value end dynamic_require_levels = %w[error warning ignore] opts.on('-D', '--dynamic-require LEVEL', dynamic_require_levels, 'Set levelDynamic require severity') do |level| [:dynamic_require_severity] = level.to_sym end opts.on('-P', '--no-source-map', 'Disable source map') do |value| [:source_map_enabled] = false end opts.on('-F', '--file FILE', 'Set filename for compiled code') do |file| [:file] = file end opts.on("--[no-]irb", "IRB var mode") do |flag| [:irb] = flag end end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options
95 96 97 |
# File 'opal/lib/opal/cli_options.rb', line 95 def @options end |