Class: HTTY::CLI::Commands::Address

Inherits:
HTTY::CLI::Command show all
Defined in:
lib/htty/cli/commands/address.rb

Overview

Encapsulates the address command.

Constant Summary

Constants included from Display

Display::FORMATS

Instance Attribute Summary

Attributes inherited from HTTY::CLI::Command

#arguments, #session

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HTTY::CLI::Command

#add_request_if_new, alias_for, aliases, build_for, command_line, complete_for?, #initialize, notify_if_cookies_cleared, raw_name, sanitize_arguments

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

This class inherits a constructor from HTTY::CLI::Command

Class Method Details

.categoryObject

Returns the name of a category under which help for the address command should appear.



8
9
10
# File 'lib/htty/cli/commands/address.rb', line 8

def self.category
  'Navigation'
end

.command_line_argumentsObject

Returns the arguments for the command-line usage of the address command.



13
14
15
# File 'lib/htty/cli/commands/address.rb', line 13

def self.command_line_arguments
  'ADDRESS'
end

.helpObject

Returns the help text for the address command.



18
19
20
# File 'lib/htty/cli/commands/address.rb', line 18

def self.help
  'Changes the address of the request'
end

.help_extendedObject

Returns the extended help text for the address command.



23
24
25
26
27
28
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
# File 'lib/htty/cli/commands/address.rb', line 23

def self.help_extended
  'Changes the address used for the request. Does not communicate with the ' +
  "host.\n"                                                                  +
  "\n"                                                                       +
  'The URL you supply can be partial. At a minimum, you must specify a '     +
  'host. The optional and required elements of an address are illustrated '  +
  "below:\n"                                                                 +
  "\n"                                                                       +
  "https://steve:[email protected]:6666/store?q=ipad#sold-to-date\n"        +
  "\\______/\\_____________/\\_______/\\___/\\____/\\_____/\\___________/\n" +
  "   1.          2.          3.     4.   5.     6.        7.\n"             +
  "\n"                                                                       +
  "1. A scheme, or protocol identifier (i.e., 'http://' or 'https://' -- "   +
  "optional)\n"                                                              +
  "2. Userinfo (e.g., 'username:password@' -- optional)\n"                   +
  "3. A host (i.e., a hostname or IP address -- required)\n"                 +
  "4. A TCP port number (i.e., ':0' through ':65535' -- optional)\n"         +
  "5. A path (optional)\n"                                                   +
  "6. A query string (e.g., '?foo=bar&baz=qux' -- optional)\n"               +
  "7. A fragment (e.g., '#fragment-name' -- optional)\n"                     +
  "\n"                                                                       +
  'If (1) is omitted, HTTP is used, except if (4) is specified as port '     +
  "443, in which case HTTPS is used.\n"                                      +
  "\n"                                                                       +
  "If (3) is omitted, host 0.0.0.0 is used.\n"                               +
  "\n"                                                                       +
  'If (4) is omitted, port 80 is used, except if (1) is specified as '       +
  "HTTPS, in which case port 443 is used.\n"                                 +
  "\n"                                                                       +
  "If (5) is omitted, the root path (i.e., '/') is used.\n"                  +
  "\n"                                                                       +
  'The console prompt shows the address for the current request.'
end

.see_also_commandsObject

Returns related command classes for the address command.



58
59
60
61
62
63
64
65
66
# File 'lib/htty/cli/commands/address.rb', line 58

def self.see_also_commands
  [HTTY::CLI::Commands::SchemeSet,
   HTTY::CLI::Commands::UserinfoSet,
   HTTY::CLI::Commands::HostSet,
   HTTY::CLI::Commands::PortSet,
   HTTY::CLI::Commands::PathSet,
   HTTY::CLI::Commands::QuerySet,
   HTTY::CLI::Commands::FragmentSet]
end

Instance Method Details

#performObject

Performs the address command.



69
70
71
72
73
74
75
# File 'lib/htty/cli/commands/address.rb', line 69

def perform
  add_request_if_new do |request|
    self.class.notify_if_cookies_cleared request do
      request.address(*arguments)
    end
  end
end