#!perl
#
# Generate human-readable documentation from package metadata.
#
# This is the driver program for the DocKnot documentation generation system.
# As much logic as possible should live in App::DocKnot rather than in this
# script.  It should be a thin wrapper.
#
# SPDX-License-Identifier: MIT

use 5.024;
use autodie;
use warnings;

use App::DocKnot::Command;

# Dispatch everything to the module.
my $docknot = App::DocKnot::Command->new();
$docknot->run();

__END__

=for stopwords
Allbery DocKnot docknot MERCHANTABILITY NONINFRINGEMENT sublicense subcommand
subcommands distdir

=head1 NAME

docknot - Generate human-readable documentation from package metadata

=head1 SYNOPSIS

B<docknot> B<-h>

B<docknot> dist [B<-m> I<metadata>] B<-d> I<distdir>

B<docknot> generate [B<-m> I<metadata>] [B<-w> I<width>] I<template> [I<output>]

B<docknot> generate-all [B<-m> I<metadata>] [B<-w> I<width>]

=head1 DESCRIPTION

B<docknot> can perform various actions related to documenting or releasing
software packages, organized into subcommands.  The supported subcommands are:

=over 4

=item dist

Build, test, and generate a distribution tarball of the package in the
current directory.  The exact commands used is determined by the package
metadata (see L<App::DocKnot::Generate> for format documentation).

After the distribution is built, it will be checked against the source tree
and B<docknot> will report an error and exit with a non-zero status if there
are any expected files missing.

=item generate

Use metadata files and templates to generate human-readable documentation
files for a package.  See L<App::DocKnot::Generate> for documentation on the
metadata format, configuration files, and paths.

=item generate-all

Like C<generate>, but generates all of the package documentation for which
default output files are configured.  This is a quick short-cut to generating
all documentation that's shipped with the package.

=back

=head1 OPTIONS

Each B<docknot> subcommand takes its own options.

=head2 Global Options

=over 4

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

Print out usage information and exit.

=back

=head2 dist

=over 4

=item B<-d> I<distdir>, B<--distdir>=I<distdir>

The directory into which to put the generated distribution tarball.  This is
also used as a working directory for a temporary copy of the package source.
This should point to a trusted directory, not one where an attacker could have
written files; see L<App::DocKnot::Dist/make_distribution()> for more
information.  Required.

=item B<-m> I<metadata>, B<--metadata>=I<metadata>

The path to the metadata files for the package whose distribution tarball is
being generated.  This should be a directory containing all the package
metadata files required by App::DocKnot.  Default: F<docs/metadata> relative
to the current directory (which is the recommended metadata path for a
project).

=back

=head2 generate

=over 4

=item B<-m> I<metadata>, B<--metadata>=I<metadata>

The path to the metadata files for the package whose documentation is being
generated.  This should be a directory containing all the package metadata
files required by App::DocKnot.  Default: F<docs/metadata> relative to the
current directory (which is the recommended metadata path for a project).

=item B<-w> I<width>, B<--width>=I<width>

Column width at which the generated output is wrapped.  Default: 74.

=item I<template>

The template to use when generating the output file.

=item I<output>

The path to the output file to generate.  If this argument isn't given, the
output file will be chosen based on the template as follows:

    readme     ->  README
    readme-md  ->  README.md

If the template isn't listed above, this argument is required.

=back

=head2 generate-all

=over 4

=item B<-m> I<metadata>, B<--metadata>=I<metadata>

The path to the metadata files for the package whose documentation is being
generated.  This should be a directory containing all the package metadata
files required by App::DocKnot.  Default: F<docs/metadata> relative to the
current directory (which is the recommended metadata path for a project).

=item B<-w> I<width>, B<--width>=I<width>

Column width at which the generated output is wrapped.  Default: 74.

=back

=head1 DIAGNOSTICS

If B<docknot> fails with errors, see the underlying module for that subcommand
for information about what those errors might mean.  Internally, it can also
produce the following diagnostics:

=over 4

=item cannot write to %s: %s

(F) The output file specified with B<-o> could not be written to.

=item missing required option %s

(F) One of the required command-line options was not given.

=item no subcommand given

(F) No subcommand was given after B<docknot> on the command line.

=item unknown command %s

(F) The given subcommand was not recognized.

=back

In addition, other L<Getopt::Long> error messages may result from invalid
command-line options.

=head1 AUTHOR

Russ Allbery <rra@cpan.org>

=head1 COPYRIGHT AND LICENSE

Copyright 2016, 2018-2020 Russ Allbery <rra@cpan.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

=head1 SEE ALSO

L<App::DocKnot::Dist>, L<App::DocKnot::Generate>

This program is part of the DocKnot distribution.  DocKnot is available from
CPAN as App::DocKnot, or directly from its web site at
L<https://www.eyrie.org/~eagle/software/docknot/>.

=cut

# Local Variables:
# copyright-at-end-flag: t
# End:
