bin: sync usage and keep it consistent in all utils.

This commit is contained in:
Juan RP 2020-04-20 21:25:14 +02:00
parent d5251a9c23
commit 9b695433a0
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368
15 changed files with 285 additions and 232 deletions

View File

@ -44,13 +44,13 @@ usage(bool fail)
" -C --config <dir> Path to confdir (xbps.d)\n"
" -d --debug Debug mode shown to stderr\n"
" -g --group <name> Group of alternatives to match\n"
" -h --help Print usage help\n"
" -h --help Show usage\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -v --verbose Verbose messages\n"
" -V --version Show XBPS version\n"
"MODE\n"
" -l --list [PKG] List all alternatives or from PKG\n"
" -s --set PKG Set alternatives for PKG\n\n");
" -s --set PKG Set alternatives for PKG\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}

View File

@ -73,29 +73,28 @@ xstrdup(const char *src)
}
static int
show_usage(const char *prog)
show_usage(const char *prog, bool fail)
{
fprintf(stderr,
"Usage: %s [OPTIONS] [FILES...]\n\n"
"OPTIONS:\n"
" -h --help Show this helpful help-message for help.\n"
" -C --config <dir> Set path to xbps.d\n"
" -D --distdir <dir> Set (or override) the path to void-packages\n"
" (defaults to ~/void-packages).\n"
" -d --debug Enable debug output to stderr.\n"
" -e --removed List packages present in repos, but not in distdir.\n"
" -f --format <fmt> Output format.\n"
" -I --installed Check for outdated packages in rootdir, rather\n"
" than in the XBPS repositories.\n"
" -i --ignore-conf-repos Ignore repositories defined in xbps.d.\n"
" -m --manual Only process listed files.\n"
" -R --repository=<url> Append repository to the head of repository list.\n"
" -r --rootdir <dir> Set root directory (defaults to /).\n"
" -s --show-all List all packages, in the format 'pkgname repover srcver'.\n"
" -h, --help Show usage\n"
" -C, --config <dir> Set path to xbps.d\n"
" -D, --distdir <dir> Set (or override) the path to void-packages\n"
" (defaults to ~/void-packages)\n"
" -d, --debug Enable debug output to stderr\n"
" -e, --removed List packages present in repos, but not in distdir\n"
" -f, --format <fmt> Output format\n"
" -I, --installed Check for outdated packages in rootdir, rather\n"
" than in the XBPS repositories\n"
" -i, --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -m, --manual Only process listed files\n"
" -R, --repository=<url> Append repository to the head of repository list\n"
" -r, --rootdir <dir> Set root directory (defaults to /)\n"
" -s, --show-all List all packages, in the format 'pkgname repover srcver'\n"
"\n [FILES...] Extra packages to process with the outdated\n"
" ones (only processed if missing).\n\n",
prog);
return EXIT_FAILURE;
" ones (only processed if missing).\n", prog);
return fail ? EXIT_FAILURE: EXIT_SUCCESS;
}
static void
@ -728,7 +727,7 @@ main(int argc, char **argv)
while ((c = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (c) {
case 'h':
return show_usage(prog);
return show_usage(prog, false);
case 'C':
rcv.xbps_conf = xstrdup(optarg);
break;
@ -765,8 +764,9 @@ main(int argc, char **argv)
case 'V':
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case '?':
default:
return show_usage(prog);
return show_usage(prog, true);
}
}
/*

View File

@ -68,54 +68,49 @@ static xbps_dictionary_t pkg_propsd, pkg_filesd, all_filesd;
static const char *destdir;
static void __attribute__((noreturn))
usage(void)
usage(bool fail)
{
fprintf(stdout,
"Usage: %s [OPTIONS] -A <arch> -n <pkgver> -s \"<desc>\" destdir\n\n"
"OPTIONS\n"
" -A --architecture Package architecture (e.g: noarch, i686, etc).\n"
" -B --built-with Package builder string (e.g: xbps-src-30).\n"
" -C --conflicts Conflicts (blank separated list,\n"
" e.g: 'foo>=2.0 blah<=2.0').\n"
" -c --changelog Changelog URL.\n"
" -D --dependencies Dependencies (blank separated list,\n"
" e.g: 'foo>=1.0_1 blah<2.1').\n"
" -F --config-files Configuration files (blank separated list,\n"
" e.g '/etc/foo.conf /etc/foo-blah.conf').\n"
" -H --homepage Homepage.\n"
" -h --help Show help.\n"
" -l --license License.\n"
" -M --mutable-files Mutable files list (blank separated list,\n"
" e.g: '/usr/lib/foo /usr/bin/blah').\n"
" -m --maintainer Maintainer.\n"
" -n --pkgver Package name/version tuple (e.g `foo-1.0_1').\n"
" -P --provides Provides (blank separated list,\n"
" e.g: 'foo-9999 blah-1.0').\n"
" -p --preserve Enable package preserve boolean.\n"
" -q --quiet Work silently.\n"
" -R --replaces Replaces (blank separated list,\n"
" e.g: 'foo>=1.0 blah<2.0').\n"
" -r --reverts Reverts (blank separated list,\n"
" e.g: '1.0_1 2.0_3').\n"
" -S --long-desc Long description (80 cols per line).\n"
" -s --desc Short description (max 80 characters).\n"
" -t --tags A list of tags/categories (blank separated list).\n"
" -V --version Prints XBPS release version.\n"
" --alternatives List of available alternatives this pkg provides.\n"
" -A, --architecture Package architecture (e.g: noarch, i686, etc)\n"
" -B, --built-with Package builder string (e.g: xbps-src-30)\n"
" -C, --conflicts Conflicts (blank separated list, e.g: 'foo>=2.0 blah<=2.0')\n"
" -c, --changelog Changelog URL\n"
" -D, --dependencies Dependencies (blank separated list, e.g: 'foo>=1.0_1 blah<2.1')\n"
" -F, --config-files Configuration files (blank separated list,\n"
" e.g '/etc/foo.conf /etc/foo-blah.conf')\n"
" -H, --homepage Homepage\n"
" -h, --help Show usage\n"
" -l, --license License\n"
" -M, --mutable-files Mutable files list (blank separated list,\n"
" e.g: '/usr/lib/foo /usr/bin/blah')\n"
" -m, --maintainer Maintainer\n"
" -n, --pkgver Package name/version tuple (e.g `foo-1.0_1')\n"
" -P, --provides Provides (blank separated list, e.g: 'foo-9999 blah-1.0')\n"
" -p, --preserve Enable package preserve boolean\n"
" -q, --quiet Work silently\n"
" -R, --replaces Replaces (blank separated list, e.g: 'foo>=1.0 blah<2.0')\n"
" -r, --reverts Reverts (blank separated list, e.g: '1.0_1 2.0_3')\n"
" -S, --long-desc Long description (80 cols per line)\n"
" -s, --desc Short description (max 80 characters)\n"
" -t, --tags A list of tags/categories (blank separated list)\n"
" -V, --version Show XBPS version\n"
" --alternatives List of available alternatives this pkg provides\n"
" This expects a blank separated list of <name>:<symlink>:<target>, e.g\n"
" 'vi:/usr/bin/vi:/usr/bin/vim foo:/usr/bin/foo:/usr/bin/blah'.\n"
" --build-options A string with the used build options.\n"
" --compression Compression format: none, gzip, bzip2, lz4, xz, zstd (default).\n"
" 'vi:/usr/bin/vi:/usr/bin/vim foo:/usr/bin/foo:/usr/bin/blah'\n"
" --build-options A string with the used build options\n"
" --compression Compression format: none, gzip, bzip2, lz4, xz, zstd (default)\n"
" --shlib-provides List of provided shared libraries (blank separated list,\n"
" e.g 'libfoo.so.1 libblah.so.2').\n"
" e.g 'libfoo.so.1 libblah.so.2')\n"
" --shlib-requires List of required shared libraries (blank separated list,\n"
" e.g 'libfoo.so.1 libblah.so.2').\n\n"
" e.g 'libfoo.so.1 libblah.so.2')\n\n"
"NOTE:\n"
" At least three flags are required: architecture, pkgver and desc.\n\n"
"EXAMPLE:\n"
" $ %s -A noarch -n foo-1.0_1 -s \"foo pkg\" destdir\n",
_PROGNAME, _PROGNAME);
exit(EXIT_FAILURE);
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
static void __attribute__((noreturn))
@ -866,7 +861,7 @@ main(int argc, char **argv)
srcrevs = optarg;
break;
case 'h':
usage();
usage(false);
break;
case 'H':
homepage = optarg;
@ -927,11 +922,14 @@ main(int argc, char **argv)
break;
case '?':
default:
usage();
usage(true);
/* NOTREACHED */
}
}
if (argc == optind)
usage();
if (argc == optind) {
usage(true);
/* NOTREACHED */
}
destdir = argv[optind];

View File

@ -110,25 +110,25 @@ die(const char *fmt, ...)
}
static void __attribute__((noreturn))
usage(void)
usage(bool fail)
{
fprintf(stdout,
"Usage: xbps-dgraph [OPTIONS] [MODE] <pkgname>\n\n"
"OPTIONS\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --graph-config <file> Path to the graph configuration file\n"
" -d --debug Debug mode shown to stderr\n"
" -h --help Print help usage\n"
" -M --memory-sync Remote repository data is fetched and stored\n"
" -C, --config <dir> Path to confdir (xbps.d)\n"
" -c, --graph-config <file> Path to the graph configuration file\n"
" -d, --debug Debug mode shown to stderr\n"
" -h, --help Show usage\n"
" -M, --memory-sync Remote repository data is fetched and stored\n"
" in memory, ignoring on-disk repodata archives.\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -R --repository Enable repository mode. This mode explicitly\n"
" -r, --rootdir <dir> Full path to rootdir\n"
" -R, --repository Enable repository mode. This mode explicitly\n"
" looks for packages in repositories.\n"
"MODE\n"
" -g --gen-config Generate a configuration file\n"
" -f --fulldeptree Generate a dependency graph\n"
" -m --metadata Generate a metadata graph (default mode)\n\n");
exit(EXIT_FAILURE);
" -g, --gen-config Generate a configuration file\n"
" -f, --fulldeptree Generate a dependency graph\n"
" -m, --metadata Generate a metadata graph (default mode)\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
static const char *
@ -558,6 +558,9 @@ main(int argc, char **argv)
/* Generate conf file. */
generate_conf_file();
exit(EXIT_SUCCESS);
case 'h':
usage(false);
/* NOTREACHED */
case 'M':
flags |= XBPS_FLAG_REPOS_MEMSYNC;
break;
@ -578,7 +581,8 @@ main(int argc, char **argv)
exit(EXIT_SUCCESS);
case '?':
default:
usage();
usage(true);
/* NOTREACHED */
}
}
@ -586,7 +590,8 @@ main(int argc, char **argv)
argv += optind;
if (!argc && !opmode) {
usage();
usage(true);
/* NOTREACHED */
}
pkg = *argv;

View File

@ -34,19 +34,18 @@
#include <xbps.h>
static void __attribute__((noreturn))
usage(void)
usage(bool fail)
{
fprintf(stdout,
"Usage: xbps-digest [options] [file] [file+N]\n"
"\n"
"OPTIONS:\n"
" -h\t\tShow usage()\n"
" -m <sha256>\tSelects the digest mode, sha256 (default)\n"
" -V\t\tPrints the xbps release version\n"
"\n"
"NOTES\n"
" If [file] not set, reads from stdin.\n");
exit(EXIT_FAILURE);
"OPTIONS\n"
" -h, --help Show usage\n"
" -m, --mode <sha256> Selects the digest mode, sha256 (default)\n"
" -V, --version Show XBPS version\n"
"\nNOTES\n"
" If [file] not set, reads from stdin\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
int
@ -56,11 +55,17 @@ main(int argc, char **argv)
char sha256[XBPS_SHA256_SIZE];
const char *mode = NULL, *progname = argv[0];
const struct option longopts[] = {
{ "mode", required_argument, NULL, 'm' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
while ((c = getopt_long(argc, argv, "m:hV", longopts, NULL)) != -1) {
switch (c) {
case 'h':
usage(false);
/* NOTREACHED */
case 'm':
mode = optarg;
break;
@ -68,9 +73,9 @@ main(int argc, char **argv)
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case '?':
case 'h':
default:
usage();
usage(true);
/* NOTREACHED */
}
}

View File

@ -132,7 +132,7 @@ addItem(const char *pkgn)
}
static void __attribute__((noreturn))
usage(const char *progname)
usage(const char *progname, bool fail)
{
fprintf(stderr, "Usage: %s [OPTIONS] /path/to/void-packages [pkg pkg+N]\n\n"
"OPTIONS\n"
@ -142,7 +142,7 @@ usage(const char *progname)
" -V, --verbose Enable verbose mode\n"
" -v, --version Show XBPS version\n"
" -h, --help Show usage\n", progname);
exit(EXIT_FAILURE);
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
/*
@ -577,6 +577,9 @@ main(int argc, char **argv)
while ((ch = getopt_long(argc, argv, "hj:l:svV", longopts, NULL)) != -1) {
switch (ch) {
case 'h':
usage(progname, false);
/* NOTREACHED */
case 's':
RebuildSystem = true;
break;
@ -592,18 +595,18 @@ main(int argc, char **argv)
case 'V':
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case 'h':
case '?':
default:
usage(progname);
/* NOT REACHED */
usage(progname, true);
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc < 1) {
usage(progname);
/* NOT REACHED */
usage(progname, true);
/* NOTREACHED */
}
/*

View File

@ -37,18 +37,18 @@
#include "../xbps-install/defs.h"
static void __attribute__((noreturn))
usage(void)
usage(bool fail)
{
fprintf(stdout,
"Usage: xbps-fetch [options] <url> <url+N>\n\n"
"OPTIONS:\n"
" -d\t\tEnable debug messages to stderr\n"
" -h\t\tShow usage()\n"
" -o <file>\tRename downloaded file to <file>\n"
" -s\t\tOutput sha256sums of the files\n"
" -v\t\tEnable verbose output\n"
" -V\t\tPrints the xbps release version\n");
exit(EXIT_FAILURE);
"OPTIONS\n"
" -d, --debug Enable debug messages to stderr\n"
" -h, --help Show usage\n"
" -o, --out <file> Rename downloaded file to <file>\n"
" -s, --sha256 Output sha256sums of the files\n"
" -v, --verbose Enable verbose output\n"
" -V, --version Show XBPS version\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
static char *
@ -92,11 +92,20 @@ main(int argc, char **argv)
struct xferstat xfer = {};
const char *filename = NULL, *progname = argv[0];
const struct option longopts[] = {
{ "out", required_argument, NULL, 'o' },
{ "debug", no_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "sha256", no_argument, NULL, 's' },
{ "version", no_argument, NULL, 'V' },
{ "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
while ((c = getopt_long(argc, argv, "o:dhsVv", longopts, NULL)) != -1) {
switch (c) {
case 'h':
usage(false);
/* NOTREACHED */
case 'o':
filename = optarg;
break;
@ -113,17 +122,19 @@ main(int argc, char **argv)
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case '?':
case 'h':
default:
usage();
usage(true);
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (!argc)
usage();
if (!argc) {
usage(true);
/* NOTREACHED */
}
/*
* Initialize libxbps.

View File

@ -43,29 +43,29 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-install [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -A --automatic Set automatic installation mode\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -D --download-only Download packages and check integrity, nothing else\n"
" -f --force Force package re-installation\n"
" -A, --automatic Set automatic installation mode\n"
" -C, --config <dir> Path to confdir (xbps.d)\n"
" -c, --cachedir <dir> Path to cachedir\n"
" -d, --debug Debug mode shown to stderr\n"
" -D, --download-only Download packages and check integrity, nothing else\n"
" -f, --force Force package re-installation\n"
" If specified twice, all files will be overwritten.\n"
" -h --help Print help usage\n"
" -i --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -I --ignore-file-conflicts Ignore detected file conflicts\n"
" -U --unpack-only Unpack packages in transaction, do not configure them\n"
" -M --memory-sync Remote repository data is fetched and stored\n"
" -h, --help Show usage\n"
" -i, --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -I, --ignore-file-conflicts Ignore detected file conflicts\n"
" -U, --unpack-only Unpack packages in transaction, do not configure them\n"
" -M, --memory-sync Remote repository data is fetched and stored\n"
" in memory, ignoring on-disk repodata archives\n"
" -n --dry-run Dry-run mode\n"
" -R,--repository <url> Add repository to the top of the list\n"
" -n, --dry-run Dry-run mode\n"
" -R, --repository <url> Add repository to the top of the list\n"
" This option can be specified multiple times\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -r, --rootdir <dir> Full path to rootdir\n"
" --reproducible Enable reproducible mode in pkgdb\n"
" -S --sync Sync remote repository index\n"
" -u --update Update target package(s)\n"
" -v --verbose Verbose messages\n"
" -y --yes Assume yes to all questions\n"
" -V --version Show XBPS version\n");
" -S, --sync Sync remote repository index\n"
" -u, --update Update target package(s)\n"
" -v, --verbose Verbose messages\n"
" -y, --yes Assume yes to all questions\n"
" -V, --version Show XBPS version\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}

View File

@ -40,16 +40,16 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-pkgdb [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -a --all Process all packages\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -d --debug Debug mode shown to stderr\n"
" -h --help Print usage help\n"
" -m --mode <auto|manual|hold|unhold|repolock|repounlock>\n"
" -a, --all Process all packages\n"
" -C, --config <dir> Path to confdir (xbps.d)\n"
" -d, --debug Debug mode shown to stderr\n"
" -h, --help Show usage\n"
" -m, --mode <auto|manual|hold|unhold|repolock|repounlock>\n"
" Change PKGNAME to this mode\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -u --update Update pkgdb to the latest format\n"
" -v --verbose Verbose messages\n"
" -V --version Show XBPS version\n");
" -r, --rootdir <dir> Full path to rootdir\n"
" -u, --update Update pkgdb to the latest format\n"
" -v, --verbose Verbose messages\n"
" -V, --version Show XBPS version\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
@ -136,8 +136,10 @@ main(int argc, char **argv)
/* NOTREACHED */
}
}
if (!update_format && !all && (argc == optind))
if (!update_format && !all && (argc == optind)) {
usage(true);
/* NOTREACHED */
}
memset(&xh, 0, sizeof(xh));
if (rootdir)

View File

@ -38,38 +38,38 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-query [OPTIONS] MODE [ARGUMENTS]\n"
"\nOPTIONS\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -h --help Print help usage\n"
" -i --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -M --memory-sync Remote repository data is fetched and stored\n"
" in memory, ignoring on-disk repodata archives.\n"
" -p --property PROP[,...] Show properties for PKGNAME\n"
" -R --repository Enable repository mode. This mode explicitly\n"
" looks for packages in repositories.\n"
" -C, --config <dir> Path to confdir (xbps.d)\n"
" -c, --cachedir <dir> Path to cachedir\n"
" -d, --debug Debug mode shown to stderr\n"
" -h, --help Show usage\n"
" -i, --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -M, --memory-sync Remote repository data is fetched and stored\n"
" in memory, ignoring on-disk repodata archives\n"
" -p, --property PROP[,...] Show properties for PKGNAME\n"
" -R, --repository Enable repository mode. This mode explicitly\n"
" looks for packages in repositories\n"
" --repository=<url> Enable repository mode and add repository\n"
" to the top of the list. This option can be\n"
" specified multiple times.\n"
" specified multiple times\n"
" --regex Use Extended Regular Expressions to match\n"
" --fulldeptree Full dependency tree for -x/--deps\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -V --version Show XBPS version\n"
" -v --verbose Verbose messages\n"
" -r, --rootdir <dir> Full path to rootdir\n"
" -V, --version Show XBPS version\n"
" -v, --verbose Verbose messages\n"
"\nMODE\n"
" -l --list-pkgs List installed packages\n"
" -L --list-repos List registered repositories\n"
" -H --list-hold-pkgs List packages on hold state\n"
" -l, --list-pkgs List installed packages\n"
" -L, --list-repos List registered repositories\n"
" -H, --list-hold-pkgs List packages on hold state\n"
" --list-repolock-pkgs List repolocked packages\n"
" -m --list-manual-pkgs List packages installed explicitly\n"
" -O --list-orphans List package orphans\n"
" -o --ownedby FILE Search for package files by matching STRING or REGEX\n"
" -S --show PKG Show information for PKG [default mode]\n"
" -s --search PKG Search for packages by matching PKG, STRING or REGEX\n"
" -m, --list-manual-pkgs List packages installed explicitly\n"
" -O, --list-orphans List package orphans\n"
" -o, --ownedby FILE Search for package files by matching STRING or REGEX\n"
" -S, --show PKG Show information for PKG [default mode]\n"
" -s, --search PKG Search for packages by matching PKG, STRING or REGEX\n"
" --cat=FILE PKG Print FILE from PKG binpkg to stdout\n"
" -f --files PKG Show package files for PKG\n"
" -x --deps PKG Show dependencies for PKG\n"
" -X --revdeps PKG Show reverse dependencies for PKG\n");
" -f, --files PKG Show package files for PKG\n"
" -x, --deps PKG Show dependencies for PKG\n"
" -X, --revdeps PKG Show reverse dependencies for PKG\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
@ -214,6 +214,7 @@ main(int argc, char **argv)
list_repolock = opmode = true;
break;
case '?':
default:
usage(true);
/* NOTREACHED */
}
@ -223,6 +224,7 @@ main(int argc, char **argv)
if (!argc && !opmode) {
usage(true);
/* NOTREACHED */
} else if (!opmode) {
/* show mode by default */
show = opmode = true;
@ -232,6 +234,7 @@ main(int argc, char **argv)
if (argc) {
/* trailing parameters */
usage(true);
/* NOTREACHED */
}
/*
* Initialize libxbps.

View File

@ -39,15 +39,15 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-reconfigure [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -a --all Process all packages\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -d --debug Debug mode shown to stderr\n"
" -f --force Force reconfiguration\n"
" -h --help Print usage help\n"
" -i --ignore PKG Ignore PKG with -a/--all\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -v --verbose Verbose messages\n"
" -V --version Show XBPS version\n");
" -a, --all Process all packages\n"
" -C, --config <dir> Path to confdir (xbps.d)\n"
" -d, --debug Debug mode shown to stderr\n"
" -f, --force Force reconfiguration\n"
" -h, --help Show usage\n"
" -i, --ignore PKG Ignore PKG with -a/--all\n"
" -r, --rootdir <dir> Full path to rootdir\n"
" -v, --verbose Verbose messages\n"
" -V, --version Show XBPS version\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
@ -147,8 +147,10 @@ main(int argc, char **argv)
/* NOTREACHED */
}
}
if (!all && (argc == optind))
if (!all && (argc == optind)) {
usage(true);
/* NOTREACHED */
}
memset(&xh, 0, sizeof(xh));
xh.state_cb = state_cb;

View File

@ -45,21 +45,21 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-remove [OPTIONS] [PKGNAME...]\n\n"
"OPTIONS\n"
" -C --config <dir> Path to confdir (xbps.d)\n"
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -F --force-revdeps Force package removal even with revdeps or\n"
" -C, --config <dir> Path to confdir (xbps.d)\n"
" -c, --cachedir <dir> Path to cachedir\n"
" -d, --debug Debug mode shown to stderr\n"
" -F, --force-revdeps Force package removal even with revdeps or\n"
" unresolved shared libraries\n"
" -f --force Force package files removal\n"
" -h --help Print help usage\n"
" -n --dry-run Dry-run mode\n"
" -O --clean-cache Remove obsolete packages in cachedir\n"
" -o --remove-orphans Remove package orphans\n"
" -R --recursive Recursively remove dependencies\n"
" -r --rootdir <dir> Full path to rootdir\n"
" -v --verbose Verbose messages\n"
" -y --yes Assume yes to all questions\n"
" -V --version Show XBPS version\n");
" -f, --force Force package files removal\n"
" -h, --help Show usage\n"
" -n, --dry-run Dry-run mode\n"
" -O, --clean-cache Remove obsolete packages in cachedir\n"
" -o, --remove-orphans Remove package orphans\n"
" -R, --recursive Recursively remove dependencies\n"
" -r, --rootdir <dir> Full path to rootdir\n"
" -v, --verbose Verbose messages\n"
" -y, --yes Assume yes to all questions\n"
" -V, --version Show XBPS version\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
@ -236,8 +236,10 @@ main(int argc, char **argv)
/* NOTREACHED */
}
}
if (!clean_cache && !orphans && (argc == optind))
if (!clean_cache && !orphans && (argc == optind)) {
usage(true);
/* NOTREACHED */
}
/*
* Initialize libxbps.

View File

@ -37,21 +37,21 @@ usage(bool fail)
fprintf(stdout,
"Usage: xbps-rindex [OPTIONS] MODE ARGUMENTS\n\n"
"OPTIONS\n"
" -d --debug Debug mode shown to stderr\n"
" -f --force Force mode to overwrite entry in add mode\n"
" -h --help Show help usage\n"
" -v --verbose Verbose messages\n"
" -V --version Show XBPS version\n"
" -C --hashcheck Consider file hashes for cleaning up packages\n"
" --compression <fmt> Compression format: none, gzip, bzip2, lz4, xz, zstd (default).\n"
" -d, --debug Debug mode shown to stderr\n"
" -f, --force Force mode to overwrite entry in add mode\n"
" -h, --help Show usage\n"
" -v, --verbose Verbose messages\n"
" -V, --version Show XBPS version\n"
" -C, --hashcheck Consider file hashes for cleaning up packages\n"
" --compression <fmt> Compression format: none, gzip, bzip2, lz4, xz, zstd (default)\n"
" --privkey <key> Path to the private key for signing\n"
" --signedby <string> Signature details, i.e \"name <email>\"\n\n"
"MODE\n"
" -a --add <repodir/pkg> ... Add package(s) to repository index\n"
" -c --clean <repodir> Clean repository index\n"
" -r --remove-obsoletes <repodir> Removes obsolete packages from repository\n"
" -s --sign <repodir> Initialize repository metadata signature\n"
" -S --sign-pkg archive.xbps ... Sign binary package archive\n\n");
" -a, --add <repodir/file.xbps> ... Add package(s) to repository index\n"
" -c, --clean <repodir> Clean repository index\n"
" -r, --remove-obsoletes <repodir> Removes obsolete packages from repository\n"
" -s, --sign <repodir> Initialize repository metadata signature\n"
" -S, --sign-pkg <file.xbps> ... Sign binary package archive\n");
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
@ -130,11 +130,16 @@ main(int argc, char **argv)
case 'V':
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case '?':
default:
usage(true);
/* NOTREACHED */
}
}
if ((argc == optind) ||
(!add_mode && !clean_mode && !rm_mode && !sign_mode && !sign_pkg_mode)) {
usage(true);
/* NOTREACHED */
} else if ((add_mode && (clean_mode || rm_mode || sign_mode || sign_pkg_mode)) ||
(clean_mode && (add_mode || rm_mode || sign_mode || sign_pkg_mode)) ||
(rm_mode && (add_mode || clean_mode || sign_mode || sign_pkg_mode)) ||

View File

@ -87,7 +87,7 @@ static SIMPLEQ_HEAD(bindmnt_head, bindmnt) bindmnt_queue =
SIMPLEQ_HEAD_INITIALIZER(bindmnt_queue);
static void __attribute__((noreturn))
usage(const char *p)
usage(const char *p, bool fail)
{
printf("Usage: %s [OPTIONS] [--] <dir> <cmd> [<cmdargs>]\n\n"
"-B, --bind-ro <src:dest> Bind mounts <src> into <dir>/<dest> (read-only)\n"
@ -96,8 +96,8 @@ usage(const char *p)
"-t, --tmpfs Creates a tempdir and mounts <dir> on tmpfs (for use with -O)\n"
"-o, --options <opts> Options to be passed to the tmpfs mount (for use with -t)\n"
"-V, --version Show XBPS version\n"
"-h, --help Show usage\n\n", p);
exit(EXIT_FAILURE);
"-h, --help Show usage\n", p);
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
static void __attribute__((noreturn))
@ -369,16 +369,21 @@ main(int argc, char **argv)
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case 'h':
usage(argv0, false);
/* NOTREACHED */
case '?':
default:
usage(argv0);
usage(argv0, true);
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc < 2)
usage(argv0);
if (argc < 2) {
usage(argv0, true);
/* NOTREACHED */
}
rootdir = argv[0];
cmd = argv[1];

View File

@ -74,11 +74,14 @@ die(const char *fmt, ...)
}
static void __attribute__((noreturn))
usage(const char *p)
usage(const char *p, bool fail)
{
printf("Usage: %s [-b src:dest] [--] <dir> <cmd> [<cmdargs>]\n\n"
"-b src:dest Bind mounts <src> into <dir>/<dest> (may be specified multiple times)\n\n", p);
exit(EXIT_FAILURE);
printf("Usage: %s [OPTIONS] [--] <dir> <cmd> [<cmdargs>]\n\n"
"OPTIONS\n"
" -b, --bind-rw <src:dest> Bind mounts <src> into <dir>/<dest> (read-write)\n"
" -h, --help Show usage\n"
" -V, --version Show XBPS version\n", p);
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
static void
@ -130,13 +133,16 @@ main(int argc, char **argv)
char **cmdargs, buf[32];
int c, fd;
const struct option longopts[] = {
{ "bind-rw", required_argument, NULL, 'b' },
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
};
chrootdir = cmd = NULL;
argv0 = argv[0];
while ((c = getopt_long(argc, argv, "b:V", longopts, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "b:hV", longopts, NULL)) != -1) {
switch (c) {
case 'b':
if (optarg == NULL || *optarg == '\0')
@ -146,16 +152,22 @@ main(int argc, char **argv)
case 'V':
printf("%s\n", XBPS_RELVER);
exit(EXIT_SUCCESS);
case 'h':
usage(argv0, false);
/* NOTREACHED */
case '?':
default:
usage(argv0);
usage(argv0, true);
/* NOTREACHED */
}
}
argc -= optind;
argv += optind;
if (argc < 2)
usage(argv0);
if (argc < 2) {
usage(argv0, true);
/* NOTREACHED */
}
chrootdir = argv[0];
cmd = argv[1];