#!perl

# Note: This script is a CLI for Riap function /App/xsum/xsum
# and generated automatically using Perinci::CmdLine::Gen version 0.502

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2025-08-25'; # DATE
our $DIST = 'App-xsum'; # DIST
our $VERSION = '0.011'; # VERSION

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/App/xsum/xsum",
    program_name => "xsum",
    read_config => 0,
    read_env => 0,
);

$cmdline->run;

# ABSTRACT: Compute and check file checksums/digests (using various algorithms)
# PODNAME: xsum

__END__

=pod

=encoding UTF-8

=head1 NAME

xsum - Compute and check file checksums/digests (using various algorithms)

=head1 VERSION

This document describes version 0.011 of xsum (from Perl distribution App-xsum), released on 2025-08-25.

=head1 SYNOPSIS

B<xsum> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)

B<xsum> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)

B<xsum> [B<L<--algorithm|/"--algorithm=s, -a">>=I<str>|B<L<-a|/"--algorithm=s, -a">>=I<str>] [B<L<--check|/"--check, -c">>|B<L<-c|/"--check, -c">>] [B<L<--digest-args|/"--digest-args=s">>=I<s>|B<L<--digest-args-json|/"--digest-args=s">>=I<json>|B<L<-A|/"--digest-args=s">>=I<s>] [(B<L<--file|/"--files-json=s">>=I<L<filename|Sah::Schema::filename>>)+|B<L<--files-json|/"--files-json=s">>=I<json>] [B<L<--files-from|/"--files-from=s, -T">>=I<L<filename|Sah::Schema::filename>>|B<L<-T|/"--files-from=s, -T">>=I<L<filename|Sah::Schema::filename>>] [B<L<--page-result|/"--page-result">>[=I<program>]|B<L<--view-result|/"--view-result">>[=I<program>]] [B<L<--tag|/"--tag">>] [B<L<--checksums-json|/"--checksums-json=s, -C">>=I<json>|(B<L<-C|/"--checksums-json=s, -C">>=I<str>)+] -- [I<L<file|/"--files-json=s">>] ...



See examples in the L</EXAMPLES> section.

=head1 DESCRIPTION

C<xsum> is a handy small utility that can be used as an alternative/replacement
for the individual per-algorithm Unix utilities like C<md5sum>, C<sha1sum>,
C<sha224sum>, and so on. It's basically the same as said Unix utilities but you
can use a single command instead.

The backend of C<xsum> is a Perl module L<File::Digest> which in turn delegates
to the individual per-algorithm backend like L<Digest::MD5>, L<Digest::SHA>,
and so on. Most of the backend modules are written in C/XS so you don't suffer
significant performance decrease.

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--algorithm>=I<s>, B<-a>

Valid values:

 ["crc32","md5","sha1","sha224","sha256","sha384","sha512","sha512224","sha512256","Digest"]

In addition to C<md5>, C<sha1> or the other algorithms, you can also specify
C<Digest> to use Perl's L<Digest> module. This gives you access to tens of
other digest modules, for example L<Digest::BLAKE2> (see examples).

When C<--digest-args> (C<-A>) is not specified, algorithm defaults to C<md5>. But
if C<--digest-args> (C<-A>) is specified, algorithm defaults to C<Digest>, for
convenience.


=item B<--check>, B<-c>

Read checksum from files and check them.

=item B<--checksums-json>=I<s>, B<-C>

Supply checksum(s) (JSON-encoded).

=item B<--digest-args-json>=I<s>, B<-A>

See C<--digest-args>.

=item B<--digest-args>=I<s>

If you use C<Digest> as the algorithm, you can pass arguments for the L<Digest>
module here.


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

(No description)


Can also be specified as the 1st command-line argument and onwards.

Can be specified multiple times.

=item B<--files-from>=I<s>, B<-T>

(No description)


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

See C<--file>.

Can also be specified as the 1st command-line argument and onwards.

=item B<--tag>

Create a BSD-style checksum.

=back

=head2 Output options

=over

=item B<--page-result>

Filter output through a pager.

This option will pipe the output to a specified pager program. If pager program
is not specified, a suitable default e.g. C<less> is chosen.


=item B<--view-result>

View output using a viewer.

This option will first save the output to a temporary file, then open a viewer
program to view the temporary file. If a viewer program is not chosen, a
suitable default, e.g. the browser, is chosen.


=back

=head2 Other options

=over

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

Display help message and exit.

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

Display program's version and exit.

=back

=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 xsum xsum

in your bash startup (e.g. F<~/.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 modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete xsum 'p/*/`xsum`/'

in your tcsh startup (e.g. F<~/.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 L<shcompgen> (see above).

=head2 other shells

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

=head1 EXAMPLES

=head2 Compute MD5 digests for some files

 % xsum -a md5 *.dat

=head2 Compute MD5 digests for some files (same as previous example, -a defaults to "md5")

 % xsum *.dat

=head2 Compute MD5 digests for some files (also same as previous example)

 % xsum -a Digest -A MD5 *.dat

=head2 Compute MD5 digests for some files (also same as previous example, -a defaults to "Digest" when -A is specified)

 % xsum -A MD5 *.dat

=head2 Compute BLAKE2b digests for some files (requirest Digest::BLAKE2 Perl module)

 % xsum -A BLAKE2,blake2b *.dat

=head2 Compute SHA1 digest for data in stdin

 % somecmd | xsum -a sha1 -

=head2 Check MD5 digests of files listed in MD5SUMS

 % xsum --check MD5SUMS

=head2 Check MD5 digest of one file

 % xsum download.exe -C 9f4b2277f50a412e56de6e0306f4afb8

=head2 Check MD5 digest of two files

 % xsum download1.exe -C 9f4b2277f50a412e56de6e0306f4afb8 download2.zip -C 62b3bf86abdfdd87e9f6a3ea7b51aa7b

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-xsum>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-xsum>.

=head1 SEE ALSO

L<shasum>. Script which comes with the perl distribution.

L<md5sum>. Unix utility.

L<sha1sum>. Unix utility.

L<sha224sum>. Unix utility.

L<sha256sum>. Unix utility.

L<sha384sum>. Unix utility.

L<sha512sum>. Unix utility.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 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 L<Dist::Zilla>,
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
L<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.

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2025 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.

=head1 BUGS

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

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.

=cut
