#!perl
our $DATE = '2014-08-24'; # DATE
our $VERSION = '0.12'; # VERSION
use 5.010;
use strict;
use warnings;
use Perinci::CmdLine 1.20;
my $cmd = 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,
},
},
default_subcommand => 'trash',
undo => 1,
);
delete $cmd->common_opts->{list};
$cmd->common_opts->{empty} = {
getopt => 'empty',
handler => sub {
my ($go, $val, $r) = @_;
$r->{subcommand_name} = 'empty';
$r->{subcommand_name_from} = '--cmd'; # XXX not exactly accurate
$r->{skip_parse_subcommand_argv} = 1;
},
};
$cmd->common_opts->{list_contents} = {
getopt => 'list-contents',
handler => sub {
my ($go, $val, $r) = @_;
$r->{subcommand_name} = 'list_contents';
$r->{subcommand_name_from} = '--cmd'; # XXX not exactly accurate
$r->{skip_parse_subcommand_argv} = 1;
},
};
$cmd->run;
1;
# ABSTRACT: Trash files, with undo/redo capability
# PODNAME: trash-u
__END__
=pod
=encoding UTF-8
=head1 NAME
trash-u - Trash files, with undo/redo capability
=head1 VERSION
This document describes version 0.12 of trash-u (from Perl distribution File-Trash-Undoable), released on 2014-08-24.
=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
# oops, 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 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/File-Trash-Undoable>.
=head1 SOURCE
Source repository is at L<https://github.com/sharyanto/perl-File-Trash-Undoable>.
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=File-Trash-Undoable>
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
Steven Haryanto <stevenharyanto@gmail.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 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