#!perl

our $DATE = '2015-02-25'; # DATE
our $VERSION = '0.06'; # VERSION

use 5.010;
use strict;
use warnings;

use Perinci::CmdLine::Any;

my $prefix = '/WWW/PAUSE/Simple/';
Perinci::CmdLine::Any->new(
    url => $prefix,
    subcommands => {
        upload     => { url => "${prefix}upload_file" },
        list       => { url => "${prefix}list_files" },
        ls         => {
            url => "${prefix}list_files",
            summary => 'Alias for list',
        },
        delete     => { url => "${prefix}delete_files" },
        rm         => {
            url => "${prefix}delete_files",
            summary => 'Alias for delete',
        },
        undelete   => { url => "${prefix}undelete_files" },
        reindex    => { url => "${prefix}reindex_files" },
        password   => { url => "${prefix}set_password" },
        #'account-info' => { url => "${prefix}set_account_info" },
    },
    log => 1,
)->run;

# ABSTRACT: An API for PAUSE
# PODNAME: pause

__END__

=pod

=encoding UTF-8

=head1 NAME

pause - An API for PAUSE

=head1 VERSION

This document describes version 0.06 of pause (from Perl distribution WWW-PAUSE-Simple), released on 2015-02-25.

=head1 SYNOPSIS

First create a config file C<~/pause.conf> containing:

 username=<Your PAUSE ID>
 password=<Your PAUSE password>

and then:

 # upload one or more files
 % pause upload Foo-Bar-0.12.tar.gz Baz-2.24.tar.gz
 % pause upload Foo-Bar-0.12.tar.gz --subdir old/2014; # upload to a subdir

 # list your files
 % pause list
 % pause list 'App-*'; # accept filenames/wildcard patterns, note: quote first
 % pause list --detail; # see file sizes/mtimes/etc instead of just names

 # delete files
 % pause delete Foo-Bar-0.12.tar.gz Foo-Bar-0.12.readme Foo-Bar-0.12.meta
 % pause delete 'Foo-Bar-*'; # accept wildcard patterns, but quote first

 # undelete files scheduled for deletion (but not actually deleted yet)
 % pause undelete Foo-Bar-0.12.tar.gz Foo-Bar-0.12.readme Foo-Bar-0.12.meta
 % pause undelete 'Foo-Bar-*'; # accept wildcard patterns, but quote first

 # force reindexing
 % pause reindex Foo-Bar-0.12.tar.gz Foo-Bar-0.12.meta
 % pause reindex 'Foo-Bar-*'; # accept wildcard patterns, but quote first

 # change your password
 ...

 # view your account info
 ...

 # change your email forwarding
 ...

=head1 SUBCOMMANDS

=head2 B<delete>

Delete files.

When a file is deleted, it is not immediately deleted but has
scheduled_for_deletion status for 72 hours, then deleted. During that time, the
file can be undeleted.


=head2 B<list>

List files on your PAUSE account.

=head2 B<ls>

Alias for list.

=head2 B<password>

=head2 B<reindex>

Force reindexing.

=head2 B<rm>

Alias for delete.

When a file is deleted, it is not immediately deleted but has
scheduled_for_deletion status for 72 hours, then deleted. During that time, the
file can be undeleted.


=head2 B<undelete>

Undelete files.

When a file is deleted, it is not immediately deleted but has
scheduled_for_deletion status for 72 hours, then deleted. During that time, the
file can be undeleted.


=head2 B<upload>

Upload file(s) to your PAUSE account.

=head1 OPTIONS

C<*> marks required options.

=head2 Common options

=over

=item B<--config-path>=I<s>

Set path to configuration file.

Can be specified multiple times.

=item B<--config-profile>=I<s>

Set configuration profile to use.

=item B<--debug>

Set log level to debug.

=item B<--format>=I<s>

Choose output format, e.g. json, text.

=item B<--help>, B<-h>, B<-?>

Display this help message.

=item B<--json>

Set output format to json.

=item B<--log-level>=I<s>

Set log level.

=item B<--naked-res>

When outputing as JSON, strip result envelope.

By default, when outputing as JSON, the full enveloped result is returned, e.g.:

    [200,"OK",[1,2,3],{"func.extra"=>4}]

The reason is so you can get the status (1st element), status message (2nd
element) as well as result metadata/extra result (4th element) instead of just
the result (3rd element). However, sometimes you want just the result, e.g. when
you want to pipe the result for more post-processing. In this case you can use
`--naked-res` so you just get:

    [1,2,3]


=item B<--no-config>

Do not use any configuration file.

=item B<--password>=I<s>*

PAUSE password.

=item B<--quiet>

Set log level to quiet.

=item B<--subcommands>

List available subcommands.

=item B<--trace>

Set log level to trace.

=item B<--username>=I<s>*

PAUSE ID.

=item B<--verbose>

Set log level to info.

=item B<--version>, B<-v>

=back

=head2 Options for subcommand delete

=over

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>*

File name/wildcard pattern.

Can be specified multiple times.

=back

=head2 Options for subcommand list

=over

=item B<--del>

Only list files which are scheduled for deletion.

=item B<--detail>

Whether to return detailed records.

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>

File name/wildcard pattern.

Can be specified multiple times.

=back

=head2 Options for subcommand ls

=over

=item B<--del>

Only list files which are scheduled for deletion.

=item B<--detail>

Whether to return detailed records.

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>

File name/wildcard pattern.

Can be specified multiple times.

=back

=head2 Options for subcommand password

=over

=back

=head2 Options for subcommand reindex

=over

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>*

File name/wildcard pattern.

Can be specified multiple times.

=back

=head2 Options for subcommand rm

=over

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>*

File name/wildcard pattern.

Can be specified multiple times.

=back

=head2 Options for subcommand undelete

=over

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>*

File name/wildcard pattern.

Can be specified multiple times.

=back

=head2 Options for subcommand upload

=over

=item B<--file-json>=I<s>

File name/wildcard pattern (JSON-encoded).

See C<--file>.

=item B<--file>=I<s@>*

File name/wildcard pattern.

Can be specified multiple times.

=item B<--subdir>=I<s>

Subdirectory to put the file(s) into.

Default value:

 ""

=back

=head1 ENVIRONMENT

PAUSE_OPT

=head1 FILES

~/pause.conf

/etc/pause.conf

=head1 COMPLETION

This script has shell tab completion capability with support for several shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C pause pause

in your bash startup (e.g. C<~/.bashrc>). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.

It is recommended, however, that you install L<shcompgen> which allows you to activate completion scripts for several kinds of scripts on multiple shells. Some CPAN distributions (those that are built with L<Dist::Zilla::Plugin::GenShellCompletion>) will even automatically enable shell completion for their included scripts (using C<shcompgen>) at installation time, so you can immadiately have tab completion.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete pause 'p/*/`pause`/'

in your tcsh startup (e.g. C<~/.tcshrc>). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.

It is also recommended to install C<shcompgen> (see above).

=head2 other shells

For fish and zsh, install C<shcompgen> as described above.

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/WWW-PAUSE-Simple>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-WWW-PAUSE-Simple>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=WWW-PAUSE-Simple>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
