Class: HTTY::CLI
Overview
Encapsulates the command-line interface to htty.
Defined Under Namespace
Modules: BodyOpenCommand, Commands, Display, HTTPMethodCommand, InputDevice, UrlEscaping Classes: Command
Constant Summary
Constants included from Display
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the HTTY::Session created from command-line arguments.
Instance Method Summary collapse
-
#formatted_prompt ⇒ Object
This is something that should belong to Display.
-
#initialize(command_line_arguments) ⇒ CLI
constructor
Instantiates a new HTTY::CLI with the specified command_line_arguments.
-
#line(command = '') ⇒ Object
This is something that should belong to Display.
-
#run! ⇒ Object
Takes over STDIN, STDOUT, and STDERR to expose #session to command-line interaction.
Methods included from Display
#break, #format, #formatted_prompt_for, #indent, #logotype, #normal, #notice, #pluralize, #rescuing_from, #say, #say_goodbye, #say_header, #say_hello, #show_headers, #show_request, #show_response, #strong, #word_wrap, #word_wrap_indented
Constructor Details
#initialize(command_line_arguments) ⇒ CLI
Instantiates a new HTTY::CLI with the specified command_line_arguments.
20 21 22 23 24 |
# File 'lib/htty/cli.rb', line 20 def initialize(command_line_arguments) handle_version(command_line_arguments) handle_help(command_line_arguments) initialize_session(command_line_arguments) end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the HTTY::Session created from command-line arguments.
17 18 19 |
# File 'lib/htty/cli.rb', line 17 def session @session end |
Instance Method Details
#formatted_prompt ⇒ Object
This is something that should belong to Display
44 45 46 |
# File 'lib/htty/cli.rb', line 44 def formatted_prompt formatted_prompt_for(@session.requests.last) end |
#line(command = '') ⇒ Object
This is something that should belong to Display
39 40 41 |
# File 'lib/htty/cli.rb', line 39 def line(command = '') puts formatted_prompt + command end |
#run! ⇒ Object
Takes over STDIN, STDOUT, and STDERR to expose #session to command-line interaction.
28 29 30 31 32 33 34 35 36 |
# File 'lib/htty/cli.rb', line 28 def run! say_hello catch :quit do HTTY::CLI::InputDevice.new(self).commands do |command_line| run_command_line(command_line) end end say_goodbye end |