Class: Forward::CLI
Defined Under Namespace
Classes: ValidationError
Constant Summary collapse
- BANNER =
<<-BANNER.gsub /^ {4}/, '' Usage: forward <port|host|host:port|path> [options] Examples: > forward 3000 # forward server running on port 3000 > forward mysite.dev # forward virtual host mysite.dev > forward ~/Dev/mysite # forward a path or directory Common Options: > forward 3000 -a foo:bar # password protect a tunnel > forward 3000 myapp # assign a static subdomain prefix > forward 3000 myapp -c my.domain.com # use a custom CNAME Options: BANNER
Constants included from Common
Class Method Summary collapse
-
.start ⇒ Object
Parses various options and arguments, validates everything to ensure we’re safe to proceed, and finally passes options to the Client.
Methods included from Common
config, exit_with_error, exit_with_message, logged_in?, logger, os, stop_reactor_and_exit, windows?
Class Method Details
.start ⇒ Object
Parses various options and arguments, validates everything to ensure we’re safe to proceed, and finally passes options to the Client.
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 |
# 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.) end |