class Forward::CLI
Constants
- BANNER
Public Class Methods
start()
click to toggle source
Parses various options and arguments, validates everything to ensure we're safe to proceed, and finally passes options to the Client.
# File lib/forward/cli.rb, line 29 def self.start HighLine.use_color = false if windows? if ARGV.include?('--debug') Forward.debug! ARGV.delete('--debug') end Forward.logger.debug("Starting forward v#{Forward::VERSION}") Slop.parse(banner: BANNER, help: true) do on '-a=', '--auth=', "Protect this tunnel with HTTP Basic Auth." on '-A', '--no-auth', "Disable authentication on this tunnel (if a default is set in your preferences)" on '-c=', '--cname=', "Allow access to this tunnel as CNAME (requires CNAME setup on your DNS server)" on '-q', '--quiet', "Don't display requests" do Forward.quiet! end on '-v', '--version', 'Display version number' do puts "forward #{VERSION}" exit end # Start / Open a Tunnel run do |opts, args| Command::Tunnel.run(:start, opts, args) end # Account Commands command 'account:login', banner: "Usage: forward account:login", help: true do description "Logs into a new account and makes it the default" run { |opts, args| Command::Account.run(:login, opts, args) } end command 'account:default', banner: "Usage: forward account:default SUBDOMAIN", help: true do description "Sets an account to the default account" run { |opts, args| Command::Account.run(:default, opts, args) } end command 'account:logout', banner: "Usage: forward account:logout SUBDOMAIN", help: true do description "Logs out of an account" run { |opts, args| Command::Account.run(:logout, opts, args) } end command 'account:list', banner: "Usage: forward account:list", help: true do description "Lists active accounts" run { |opts, args| Command::Account.run(:list, opts, args) } end end rescue CLIError => e exit_with_error(e.message) end