#!/usr/bin/perl

use 5.010;
use strict;
use warnings;
use Perinci::CmdLine;

our $VERSION = '0.07'; # VERSION

Perinci::CmdLine->new(
    url => '/File/Trash/Undoable/',
    subcommands => {
        trash         => {
            url  => '/File/Trash/Undoable/trash_files',
        },
        list_contents => {
            url  => '/File/Trash/Undoable/list_trash_contents',
            undo => 0,
        },
        empty         => {
            url  => '/File/Trash/Undoable/empty_trash',
            pass_cmdline_object => 1,
            undo => 0,
        },
    },
    extra_opts => {
        empty => {
            handler => sub {
                my $self = shift;
                $self->{_selected_subcommand} = 'empty';
            },
        },
        list_contents => {
            handler => sub {
                my $self = shift;
                $self->{_selected_subcommand} = 'list_contents';
            },
        },
    },
    default_subcommand => 'trash',
    undo => 1,
)->run;

1;
# ABSTRACT: Trash files, with undo/redo capability
# PODNAME: trash-u


__END__
=pod

=head1 NAME

trash-u - Trash files, with undo/redo capability

=head1 VERSION

version 0.07

=head1 SYNOPSIS

 # trash some files, but in simulation mode, not really trashing the files
 % VERBOSE=1 trash-u --dry-run *.bak

 # trash some files, for real
 % trash-u *.bak

 # list trash contents
 % trash-u --list-contents

 # trash some more files
 % trash-u * .tmp

 # ups made a mistake; no worry, let's undo; now previous trashing is reversed
 % trash-u --undo

 # undo again; now the *.bak files are also restored
 % trash-u --undo

 # redo; now the *.bak files are trashed again
 % trash-u --redo

 # show history
 % trash-u --history

 # forget history; past actions can no longer be undone/redone
 % trash-u --clear-history

 # empty trash; this action is not undoable (the point is to reclaim space)
 % trash-u --empty

 # display help for more options
 % trash-u --help

=head1 DESCRIPTION

This command-line program is an interface to L<File::Trash::Undoable>, which in
turn uses L<File::Trash::FreeDesktop>.

Features: undo/redo, dry run mode, per-filesystem trash dir.

This program is relatively new and have not yet been tested extensively. Use
with caution.

=head1 USING AS rm REPLACEMENT

B<trash-u> can be used as B<rm> replacement (a.k.a. alias) with some caveats:

=over 4

=item * trash-u deletes directories by default

That is, it behaves as if -R rm option is in effect.

=item * Some rm options exist but do not have any effect (noop)

=item * Some rm options are still missing/unknown

This include: C<-i>/C<-I>/C<--interactive>, C<--one-file-system>,
C<--no-preserve-root>.

=back

=head1 SEE ALSO

L<File::Trash::Undoable>

L<File::Trash::FreeDesktop>

B<trash-cli>

B<gvfs-trash>

B<rmv>

=head1 AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Steven Haryanto.

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

