Class: Opal::CLIOptions
- Inherits:
-
OptionParser
- Object
- OptionParser
- 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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'opal/lib/opal/cli_options.rb', line 5 def initialize super @options = {} self. = 'Usage: opal [options] -- [programfile]' separator '' on('-v', '--verbose', 'print version number, then turn on verbose mode') do print_version exit if ARGV.empty? [:verbose] = true end on('--verbose', 'turn on verbose mode (set $VERBOSE to true)') do [:verbose] = true end on('-d', '--debug', 'turn on debug mode (set $DEBUG to true)') do [:debug] = true end on('--version', 'Print the version') do print_version exit end on("-h", "--help", "Show this message") do puts self exit end section 'Basic Options:' on('-I', '--include DIR', 'Append a load path (may be used more than once)') do |i| [:load_paths] ||= [] [:load_paths] << i end on('-e', '--eval SOURCE', String, 'One line of script. Several -e\'s allowed. Omit [programfile]') do |source| [:evals] ||= [] [:evals] << source end on('-r', '--require LIBRARY', String, 'Require the library before executing your script') do |library| [:requires] ||= [] [:requires] << library end on('-s', '--stub FILE', String, 'Stubbed files will be compiled as empty files') do |stub| [:stubs] ||= [] [:stubs] << stub end on('-p', '--preload FILE', String, 'Preloaded files will be prepared for dynamic requires') do |stub| [:preload] ||= [] [:preload] << stub end on('-g', '--gem GEM_NAME', String, 'Adds the specified GEM_NAME to Opal\'s load path.') do |g| [:gems] ||= [] [:gems] << g end section 'Running Options:' on('--sexp', 'Show Sexps') do [:sexp] = true end on('-m', '--map', 'Show sourcemap') do [:map] = true end on('-c', '--compile', 'Compile to JavaScript') do [:compile] = true end on('-R', '--runner RUNNER', %w[nodejs server phantomjs applescript nashorn], 'Choose the runner: nodejs (default), server') do |runner| [:runner] = runner.to_sym end on('--server-port PORT', 'Set the port for the server runner (default port: 3000)') do |port| [:runner] = :server [:port] = port.to_i end on('-E', '--no-exit', 'Do not append a Kernel#exit at the end of file') do |no_exit| [:no_exit] = true end section 'Compilation Options:' on('-M', '--no-method-missing', 'Enable/Disable method missing') do [:method_missing] = false end on('-O', '--no-opal', 'Enable/Disable implicit `require "opal"`') do [:skip_opal_require] = true end on('-A', '--arity-check', 'Enable arity check') do [:arity_check] = true end on('-V', 'Enable inline Operators') do [:inline_operators] = true end dynamic_require_levels = %w[error warning ignore] on('-D', '--dynamic-require LEVEL', dynamic_require_levels, 'Set level of dynamic require severity.', "(default: error, values: #{dynamic_require_levels.join(', ')})") do |level| [:dynamic_require_severity] = level.to_sym end on('-P', '--source-map [FILE]', 'Enable/Disable source map') do |file| [:source_map_enabled] = true [:source_map_file] = file if file end on('-F', '--file FILE', 'Set filename for compiled code') do |file| [:file] = file end on("--irb", "Enable IRB var mode") do [:irb] = true end separator '' end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options
142 143 144 |
# File 'opal/lib/opal/cli_options.rb', line 142 def @options end |