Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Devtools\Bin\Paste Class Reference
Inheritance diagram for Hoa\Devtools\Bin\Paste:

Public Member Functions

 main ()
 
 usage ()
 
- Public Member Functions inherited from Hoa\Console\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 getOption (&$optionValue, $short=null)
 
 setOptions (Array $options)
 
 makeUsageOptionsList (Array $definitions=[])
 
 resolveOptionAmbiguity (Array $solutions)
 
 status ($text, $status)
 
 readLine ($prefix=null)
 
 readPassword ($prefix=null)
 
- Public Member Functions inherited from Hoa\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 construct ()
 

Protected Attributes

 $options
 
- Protected Attributes inherited from Hoa\Console\Dispatcher\Kit
 $options = null
 
 $_options = null
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Console\Dispatcher\Kit
 $parser = null
 
- Public Attributes inherited from Hoa\Dispatcher\Kit
 $router = null
 
 $dispatcher = null
 
 $view = null
 
 $data = null
 

Detailed Description

Class .

Paste something somewhere.

Definition at line 49 of file Paste.php.

Member Function Documentation

Hoa\Devtools\Bin\Paste::main ( )

The entry method.

Returns
int

Definition at line 69 of file Paste.php.

70  {
71  $address = 'paste.hoa-project.net:80';
72 
73  while (false !== $c = $this->getOption($v)) {
74  switch ($c) {
75  case 'a':
76  $address = $v;
77 
78  break;
79 
80  case 'h':
81  case '?':
82  return $this->usage();
83 
84  case '__ambiguous':
85  $this->resolveOptionAmbiguity($v);
86 
87  break;
88  }
89  }
90 
91  $input = file_get_contents('php://stdin');
92  $context = stream_context_create([
93  'http' => [
94  'method' => 'POST',
95  'header' => 'Host: ' . $address . "\r\n" .
96  'User-Agent: Hoa' . "\r\n" .
97  'Accept: */*' . "\r\n" .
98  'Content-Type: text/plain' . "\r\n" .
99  'Content-Length: ' . strlen($input) . "\r\n",
100  'content' => $input
101  ]
102  ]);
103 
104  echo file_get_contents('http://' . $address, false, $context), "\n";
105 
106  return;
107  }
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190

Here is the call graph for this function:

Hoa\Devtools\Bin\Paste::usage ( )

The command usage.

Returns
int

Definition at line 114 of file Paste.php.

115  {
116  echo
117  'Usage : devtools:paste <options>', "\n",
118  'Options :', "\n",
119  $this->makeUsageOptionsList([
120  'a' => 'Address to the paste server.',
121  'help' => 'This help.'
122  ]), "\n";
123 
124  return;
125  }
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Hoa\Devtools\Bin\Paste::$options
protected
Initial value:

Definition at line 56 of file Paste.php.


The documentation for this class was generated from the following file: