Sha256: 0dd088031fcf2d5a0a00ea1598a2b9420d1c2f442285f60dc2c4e47cd513e17b

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby

require 'alda-rb'
require 'optparse'

HELP = 'Print this help message and exit'.freeze
HOST = 'The hostname of the Alda REPL server; only useful in Alda 2; see `alda repl --help`'.freeze
PORT = 'The port of the Alda REPL server; only useful in Alda 2; see `alda repl --help`'.freeze
NO_COLOR = 'Whether the output should not be colored'.freeze
NO_PREVIEW = 'Whether a preview of what Alda code will not be played everytime you input ruby codes'.freeze
NO_RELINE = 'Whether to use Reline to read input'.freeze

host = 'localhost'
port = -1
color = true
preview = true
reline = true

OptionParser.new do |opts|
	opts.banner = 'Usage: alda-irb [options]'
	opts.on('-h', '--help', HELP) { exit unless puts opts }
	opts.on('-H', '--host string', HOST) { host = _1 }
	opts.on('-p', '--port int', PORT) { port = _1 }
	opts.on('-c', '--no-color', NO_COLOR) { color = false }
	opts.on('-P', '--no-preview', NO_PREVIEW) { preview = false }
	opts.on('-r', '--no-reline', NO_RELINE) { reline = false }
end.parse!

Alda.deduce_generation
opts = { color: color, preview: preview, reline: reline }
opts.merge! host: host, port: port unless Alda.v1?
Alda::REPL.new(**opts).run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alda-rb-0.3.1 exe/alda-irb