Mojolicious-Command-snoodoc

 view release on metacpan or  search on metacpan

lib/Mojolicious/Command/snoodoc.pm  view on Meta::CPAN

                $param .= ': ' . $param_desc->text;
            }

            # indentation
            " $param";
        }
    )->join("\n\n");

    $self->_pretty_print($title, $scopes, $desc, $params);
}

sub run {
    my ($self, @args) = @_;

    GetOptionsFromArray(
        \@args,    #
        'all|a' => \my $all,
    );

    if ($all) {
        $self->_print_all_endpoints();
        return;
    }

    # assuming only one endpoint was given
    my $endpoint = shift @args;

    # do not continue without endpoint
    unless ($endpoint) {
        print $self->usage;
        return;
    }

    $endpoint =~ s@^/@@;     # remove leading /
    $endpoint =~ s@/@_@g;    # look like URL fragment

    my @containers = $self->ua->get($self->url)->res->dom->find('div[id*=' . $endpoint . ']')->each(
        sub {
            $self->_get_info($_);
        }
    );

    unless (@containers) {
        print "No endpoint matching that text was found.\n";
        return;
    }
}

1;
__END__

=encoding utf-8

=head1 NAME

Mojolicious::Command::snoodoc - Quick reference tool for the Reddit API

=head1 SYNOPSIS

  $ mojo snoodoc /api/save | less
  $ mojo snoodoc /api/v1/me/prefs | less
  $ mojo snoodoc --all

=head1 DESCRIPTION

Easily print out documentation of specific Reddit API endpoints. Output
shows a description of the given endpoint, along with any OAuth scopes
and parameters.

See the reddit L<documentation|http://www.reddit.com/dev/api> for details.

=head1 AUTHOR

Curtis Brandt E<lt>curtis@cpan.orgE<gt>

=head1 COPYRIGHT

Copyright 2015- Curtis Brandt

=head1 LICENSE

The (two-clause) FreeBSD License. See LICENSE for details.

=head1 SEE ALSO

L<Mojo::Snoo>

L<reddit documentation|http://www.reddit.com/dev/api>

=cut



( run in 2.823 seconds using v1.01-cache-2.11-cpan-d7f47b0818f )