Skip to content

Commit

Permalink
add cURL-style -u for username/password entry to the get command
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed Jan 24, 2018
1 parent dde6b9e commit e094c16
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Mojolicious/Command/get.pm
Expand Up @@ -5,6 +5,7 @@ use Mojo::DOM;
use Mojo::IOLoop;
use Mojo::JSON qw(encode_json j);
use Mojo::JSON::Pointer;
use Mojo::URL;
use Mojo::UserAgent;
use Mojo::Util qw(decode encode getopt);
use Scalar::Util 'weaken';
Expand All @@ -31,6 +32,7 @@ sub run {
'o|connect-timeout=i' => sub { $ua->connect_timeout($_[1]) },
'r|redirect' => \my $redirect,
'S|response-size=i' => sub { $ua->max_response_size($_[1]) },
'u|user=s' => \my $user,
'v|verbose' => \my $verbose;

@args = map { decode 'UTF-8', $_ } @args;
Expand All @@ -44,6 +46,9 @@ sub run {
$url !~ m!^/! ? $ua->proxy->detect : $ua->server->app($self->app);
$ua->max_redirects(10) if $redirect;

# inject userinfo
$url = Mojo::URL->new($url)->userinfo($user) if $user;

my $buffer = '';
$ua->on(
start => sub {
Expand Down Expand Up @@ -176,6 +181,8 @@ Mojolicious::Command::get - Get command
-r, --redirect Follow up to 10 redirects
-S, --response-size <size> Maximum response size in bytes,
defaults to 2147483648 (2GiB)
-u, --user Alternate mechanism for specifying
colon-separated username and password
-v, --verbose Print request and response headers to
STDERR
Expand Down

0 comments on commit e094c16

Please sign in to comment.