NAME
App::TrashUtils - Utilities related to desktop trash
VERSION
This document describes version 0.003 of App::TrashUtils (from Perl
distribution App-TrashUtils), released on 2023-08-06.
DESCRIPTION
This distributions provides the following command-line utilities:
* trash-list
* trash-list-trashes
* trash-put
* trash-restore
* trash-rm
Prior to "App::TrashUtils", there is already "trash-cli" [1] which is
written in Python. App::TrashUtils aims to scratch some itches and
offers some enhancements:
* trash-restore accepts multiple arguments
* trash-list accepts files/wildcard patterns
* dry-run mode
* tab completion
* written in Perl
Lastly, App::TrashUtils is written in Perl and is easier to hack for
Perl programmers.
FUNCTIONS
trash_list
Usage:
trash_list(%args) -> [$status_code, $reason, $payload, \%result_meta]
List contents of trash directories.
Examples:
* List all files in trash cans:
trash_list();
* List files ending in ".pm" in trash cans, show details:
trash_list(wildcard => "*.pm", detail => 1);
* List all files under the path "/home/ujang/Documents" in trash cans:
trash_list(wildcard => "/home/ujang/Documents/**");
This function is not exported.
Arguments ('*' denotes required arguments):
* detail => *bool*
(No description)
* wildcard => *str*
Filter path or filename with wildcard pattern.
Will be matched against path if pattern contains "/", otherwise will
be matched against filename. Supported patterns are jokers ("*" and
"?"), character class (e.g. "[123]"), and globstar ("**").
When specifying the wildcard on the CLI, remember to quote it to
protect from being interpreted by the shell, e.g. to match files in
the current directory.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
trash_list_trashes
Usage:
trash_list_trashes() -> [$status_code, $reason, $payload, \%result_meta]
List trash directories.
This function is not exported.
No arguments.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
trash_put
Usage:
trash_put(%args) -> [$status_code, $reason, $payload, \%result_meta]
Put files into trash.
Examples:
* Trash two files:
trash_put(files => ["file1", "file2.txt"]);
This function is not exported.
This function supports dry-run operation.
Arguments ('*' denotes required arguments):
* files* => *array[pathname]*
(No description)
Special arguments:
* -dry_run => *bool*
Pass -dry_run=>1 to enable simulation mode.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
trash_restore
Usage:
trash_restore(%args) -> [$status_code, $reason, $payload, \%result_meta]
Put trashed files back into their original path.
Examples:
* Restore two files named "f1" and "f2" from trash:
trash_restore(files => ["f1", "f2"]);
* Restore all .pl and .pm files from trash:
trash_restore(files => ["*.pl", "*.pm"]);
This function is not exported.
This function supports dry-run operation.
Arguments ('*' denotes required arguments):
* files* => *array[str]*
Wildcard pattern will be interpreted (unless when --no-wildcard
option is specified).
* no_wildcard => *true*
(No description)
Special arguments:
* -dry_run => *bool*
Pass -dry_run=>1 to enable simulation mode.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
trash_rm
Usage:
trash_rm(%args) -> [$status_code, $reason, $payload, \%result_meta]
Permanently remove files in trash.
Examples:
* Permanently remove files named "f1" and "f2" in trash:
trash_rm(files => ["f1", "f2"]);
* Permanently remove all .pl and .pm files in trash:
trash_rm(files => ["*.pl", "*.pm"]);
This function is not exported.
This function supports dry-run operation.
Arguments ('*' denotes required arguments):
* files* => *array[str]*
Wildcard pattern will be interpreted (unless when --no-wildcard
option is specified).
* no_wildcard => *true*
(No description)
Special arguments:
* -dry_run => *bool*
Pass -dry_run=>1 to enable simulation mode.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
HOMEPAGE
Please visit the project's homepage at
<https://metacpan.org/release/App-TrashUtils>.
SOURCE
Source repository is at
<https://github.com/perlancar/perl-App-TrashUtils>.
SEE ALSO
[1] <https://github.com/andreafrancia/trash-cli>, Python-based CLIs
delated to desktop trash.
File::Trash::FreeDesktop
Alternative CLI's: trash-u (from App::trash::u) which supports undo.
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull
requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You
can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally
on your system), you can install Dist::Zilla,
Dist::Zilla::PluginBundle::Author::PERLANCAR,
Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by perlancar <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.
BUGS
Please report any bugs or feature requests on the bugtracker website
<https://rt.cpan.org/Public/Dist/Display.html?Name=App-TrashUtils>
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.