lib/arql/cli.rb in arql-0.1.2 vs lib/arql/cli.rb in arql-0.1.3
- old
+ new
@@ -12,11 +12,12 @@
def parse_options!
@options = OpenStruct.new(adapter: 'mysql2',
encoding: 'utf8',
pool: 5,
config_file: default_config_file,
- initializer: default_initializer)
+ initializer: default_initializer,
+ ssh: {})
OptionParser.new do |opts|
opts.banner = <<~EOF
Usage: arql [options] [ruby file]
@@ -32,66 +33,86 @@
opts.on('-iINITIALIZER', '--initializer=INITIALIZER', 'Specify initializer ruby file, default is $HOME/.arql.rb, or $HOME/.arql.d/init.rb.') do |initializer|
@options.initializer = initializer
end
- opts.on('-EENVIRON', '--env=ENVIRON', 'Specify config environment.') do |env|
+ opts.on('-eENVIRON', '--env=ENVIRON', 'Specify config environment.') do |env|
@options.env = env
end
opts.on('-jJAVA_CONFIG', '--java-conf=JAVA_CONFIG', 'Use JDBC config in JAVA_CONFIG file, if directory sepcified, first *.properties/*.yml file found in the directory will be used') do |config_file|
@options.config_file = config_file
end
- opts.on('-ADB_ADAPTER', '--db-adapter=DB_ADAPTER', 'Specify DB Adapter, default is mysql2') do |db_adapter|
+ opts.on('-aDB_ADAPTER', '--db-adapter=DB_ADAPTER', 'Specify database Adapter, default is mysql2') do |db_adapter|
@options.dapter = db_adapter
end
- opts.on('-HDB_HOST', '--db-host=DB_HOST', 'Specify DB host, if specified -E option will be ignored') do |db_host|
+ opts.on('-hDB_HOST', '--db-host=DB_HOST', 'Specify database host') do |db_host|
@options.host = db_host
end
- opts.on('-PDB_PORT', '--db-port=DB_PORT', 'Specify DB port, if specified -E option will be ignored') do |db_port|
+ opts.on('-pDB_PORT', '--db-port=DB_PORT', 'Specify database port') do |db_port|
@options.port = db_port.to_i
end
- opts.on('-DDB_NAME', '--db-name=DB_NAME', 'Specify database name, if specified -E option will be ignored') do |db_name|
+ opts.on('-dDB_NAME', '--db-name=DB_NAME', 'Specify database name') do |db_name|
@options.database = db_name
end
- opts.on('-UDB_USER', '--db-user=DB_USER', 'Specify database user, if specified -E option will be ignored') do |db_user|
+ opts.on('-uDB_USER', '--db-user=DB_USER', 'Specify database user') do |db_user|
@options.username = db_user
end
- opts.on('-pDB_PASSWORD', '--db-password=DB_PASSWORD', 'Specify database password, if specified -E option will be ignored') do |db_password|
+ opts.on('-PDB_PASSWORD', '--db-password=DB_PASSWORD', 'Specify database password') do |db_password|
@options.password = db_password
end
- opts.on('-n', '--db-encoding=DB_ENCODING', 'Specify database encoding, default is UTF-8') do |db_encoding|
+ opts.on('-n', '--db-encoding=DB_ENCODING', 'Specify database encoding, default is utf8') do |db_encoding|
@options.encoding = db_encoding
end
opts.on('-o', '--db-pool=DB_POOL', 'Specify database pool size, default is 5') do |db_pool|
@options.pool = db_pool
end
- opts.on('-eCODE', '--eval=CODE', 'evaluate CODE') do |code|
+ opts.on('-HSSH_HOST', '--ssh-host=SSH_HOST', 'Specify SSH host') do |ssh_host|
+ @options.ssh[:host] = ssh_host
+ end
+
+ opts.on('-OSSH_PORT', '--ssh-port=SSH_PORT', 'Specify SSH port') do |ssh_port|
+ @options.ssh[:port] = ssh_port.to_i
+ end
+
+ opts.on('-USSH_USER', '--ssh-user=SSH_USER', 'Specify SSH user') do |ssh_user|
+ @options.ssh[:user] = ssh_user
+ end
+
+ opts.on('-WSSH_PASSWORD', '--ssh-password=SSH_PASSWORD', 'Specify SSH password') do |ssh_password|
+ @options.ssh[:password] = ssh_password
+ end
+
+ opts.on('-LSSH_LOCAL_PORT', '--ssh-local-port=SSH_LOCAL_PORT', 'Specify local SSH proxy port') do |local_port|
+ @options.ssh[:local_port] = local_port.to_i
+ end
+
+ opts.on('-ECODE', '--eval=CODE', 'evaluate CODE') do |code|
@options.code = code
end
- opts.on('-s', '--show-sql', 'Show SQL on STDOUT') do
+ opts.on('-S', '--show-sql', 'Show SQL on STDOUT') do
@options.show_sql = true
end
opts.on('-wOUTOUT', '--write-sql=OUTPUT', 'Write SQL to OUTPUT file') do |file|
@options.write_sql = file
end
- opts.on('-aOUTPUT', '--append-sql=OUTPUT', 'Append SQL to OUTPUT file') do |file|
+ opts.on('-AOUTPUT', '--append-sql=OUTPUT', 'Append SQL to OUTPUT file') do |file|
@options.append_sql = file
end
- opts.on('-h', '--help', 'Prints this help') do
+ opts.on('', '--help', 'Prints this help') do
puts opts
exit
end
end.parse!