// file      : bpkg/rep-info.cli
// license   : MIT; see accompanying LICENSE file

include <libbpkg/manifest.hxx>;

include <bpkg/common.cli>;

"\section=1"
"\name=bpkg-rep-info"
"\summary=print repository information"

namespace bpkg
{
  {
    "<options> <rep-loc>",

    "\h|SYNOPSIS|

     \c{\b{bpkg rep-info} [<options>] <rep-loc>}

     \h|DESCRIPTION|

     The \cb{rep-info} command prints various information about the specified
     repository. By default it print the repository's name and location as the
     first line. If the repository is signed, the certificate information
     (name/organization/email) is printed as the next line followed by the
     certificate fingerprint. Then comes the list of complement and
     prerequisite repositories followed by the list of available packages.

     This default format can be altered in various ways using options listed
     below. Note also that the information is written to \cb{stdout}, not
     \cb{stderr}.

     If the current working directory contains a \cb{bpkg} configuration, then
     \cb{rep-info} will use its certificate database for the repository
     authentication. That is, it will trust the repository's certificate if it
     is already trusted by the configuration. Otherwise it will add the
     certificate to the configuration if you confirm it is trusted. You can
     specify an alternative configuration directory with the
     \cb{--directory|-d} option. To disable using the configuration in the
     current working directory pass this option with an empty path."
  }

  class rep_info_options: common_options
  {
    "\h|REP-INFO OPTIONS|"

    bool --name|-n
    {
      "Print the repository's name and location."
    }

    bool --cert-fingerprint
    {
      "Print the repository's certificate fingerprint or empty line if the
       repository is unsigned."
    }

    bool --cert-name
    {
      "Print the repository's certificate common name (CN) or empty line if
       the repository is unsigned."
    }

    bool --cert-organization
    {
      "Print the repository's certificate organization name (O) or empty line
       if the repository is unsigned."
    }

    bool --cert-email
    {
      "Print the repository's certificate email or empty line if the
       repository is unsigned."
    }

    bool --repositories|-r
    {
      "Print the list of complement and prerequisite repositories."
    }

    bool --packages|-p
    {
      "Print the list of available packages."
    }

    bool --manifest
    {
      "Instead of printing the information in the human-readable form, dump it
       (to \cb{stdout}) as manifest(s). Normally you would use this option in
       combination with \cb{--packages|-p} or \cb{--repositories|-r} to only
       dump one of the manifests. If the \cb{--deep} option is specified, then
       in the resulting packages manifest the \cb{*-file} values are replaced
       with the contents of the referenced files and the \c{*-build} values
       are automatically added (unless the corresponding files are
       absent). See also \cb{--ignore-unknown}, \cb{--repositories-file}, and
       \cb{--packages-file}."
    }

    bool --ignore-unknown
    {
      "Ignore unknown manifest entries. Note that this option also ignores
       the version constraints in the special toolchain build-time
       dependencies. This option is implied if \cb{--manifest} is not
       specified."
    }

    bool --deep
    {
      "Verify the presence of the required \c{*-build} values/files and
       the validity of files referenced by the \cb{*-file} manifest values."
    }

    path --repositories-file
    {
      "<path>",
      "If \cb{--manifest} is specified, then save the repositories manifest
       to the specified file instead of dumping it to \cb{stdout}."
    }

    path --packages-file
    {
      "<path>",
      "If \cb{--manifest} is specified, then save the packages manifest to the
       specified file instead of dumping it to \cb{stdout}."
    }

    repository_type --type
    {
      "<type>",
      "Specify the repository type with valid values being \cb{pkg},
       \cb{dir}, and \cb{git}. Refer to \l{bpkg-rep-add(1)} for details."
    }

    string --directory|-d // String to allow empty value.
    {
      "<dir>",
      "Use configuration in <dir> for the trusted certificate database."
    }
  };

  "
   \h|DEFAULT OPTIONS FILES|

   See \l{bpkg-default-options-files(1)} for an overview of the default
   options files. If the \cb{rep-info} command uses an existing \c{bpkg}
   configuration, then the start directory is the configuration directory.
   Otherwise, only the predefined directories (home, system, etc) are
   searched. The following options files are searched for in each directory
   and, if found, loaded in the order listed:

   \
   bpkg.options
   bpkg-rep-info.options
   \

   The following \cb{rep-info} command options cannot be specified in the
   default options files:

   \
   --directory|-d
   \
  "
}
