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

+ (Object) category

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



21
22
23
# File 'lib/htty/cli/commands/address.rb', line 21

def self.category
  'Navigation'
end

+ (Object) command_line_arguments

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



26
27
28
# File 'lib/htty/cli/commands/address.rb', line 26

def self.command_line_arguments
  'ADDRESS'
end

+ (Object) help

Returns the help text for the address command.



31
32
33
# File 'lib/htty/cli/commands/address.rb', line 31

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

+ (Object) help_extended

Returns the extended help text for the address command.



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
# File 'lib/htty/cli/commands/address.rb', line 36

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:woodside@apple.com: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

+ (Object) see_also_commands

Returns related command classes for the address command.



71
72
73
74
75
76
77
78
79
# File 'lib/htty/cli/commands/address.rb', line 71

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

- (Object) perform

Performs the address command.



82
83
84
85
86
87
88
# File 'lib/htty/cli/commands/address.rb', line 82

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