From 5daca6ebb35742a02f97ca1006d93094f6618110 Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Mon, 12 Aug 2024 14:18:05 -0400 Subject: [PATCH] Add support for brief for mport.list --- libexec/mport.info/mport.info.c | 2 +- libexec/mport.list/mport.list.c | 8 ++++++-- libmport/list.c | 2 ++ libmport/mport.h | 3 ++- libmport/mport_private.h | 2 +- libmport/util.c | 5 ++++- mport/mport.c | 9 +++++++-- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/libexec/mport.info/mport.info.c b/libexec/mport.info/mport.info.c index 9fdb983..74faf4f 100644 --- a/libexec/mport.info/mport.info.c +++ b/libexec/mport.info/mport.info.c @@ -87,7 +87,7 @@ main(int argc, char *argv[]) { mport = mport_instance_new(); - if (mport_instance_init(mport, NULL, NULL, false, mport_verbosity(quiet, verbose)) != MPORT_OK) { + if (mport_instance_init(mport, NULL, NULL, false, mport_verbosity(quiet, verbose, false)) != MPORT_OK) { warnx("%s", mport_err_string()); mport_instance_free(mport); exit(EXIT_FAILURE); diff --git a/libexec/mport.list/mport.list.c b/libexec/mport.list/mport.list.c index 6d532f9..a21dfec 100644 --- a/libexec/mport.list/mport.list.c +++ b/libexec/mport.list/mport.list.c @@ -50,6 +50,7 @@ main(int argc, char *argv[]) bool noIndex = false; bool quiet = false; bool verbose = false; + bool brief = false; const char *chroot_path = NULL; @@ -61,8 +62,11 @@ main(int argc, char *argv[]) printOpts.locks = false; printOpts.origin = false; - while ((ch = getopt(argc, argv, "c:lopqvuU")) != -1) { + while ((ch = getopt(argc, argv, "bc:lopqvuU")) != -1) { switch (ch) { + case 'b': + brief = true; + break; case 'c': chroot_path = optarg; break; @@ -101,7 +105,7 @@ main(int argc, char *argv[]) } mport = mport_instance_new(); - if (mport_instance_init(mport, NULL, NULL, noIndex, mport_verbosity(quiet, verbose)) != MPORT_OK) { + if (mport_instance_init(mport, NULL, NULL, noIndex, mport_verbosity(quiet, verbose, brief)) != MPORT_OK) { warnx("%s", mport_err_string()); exit(EXIT_FAILURE); } diff --git a/libmport/list.c b/libmport/list.c index a221221..c8be135 100644 --- a/libmport/list.c +++ b/libmport/list.c @@ -114,6 +114,8 @@ mport_list_print(mportInstance *mport, mportListPrint *print) mport_index_entry_free_vec(iestart); indexEntries = NULL; + } else if (mport->verbosity == MPORT_VBRIEF) { + mport_call_msg_cb(mport, "%s-%s", (*packs)->name, (*packs)->version); } else if (mport->verbosity == MPORT_VVERBOSE || print->verbose) { comment = mport_str_remove((*packs)->comment, '\\'); snprintf(name_version, 30, "%s-%s", (*packs)->name, (*packs)->version); diff --git a/libmport/mport.h b/libmport/mport.h index 05fb280..be347bc 100644 --- a/libmport/mport.h +++ b/libmport/mport.h @@ -52,11 +52,12 @@ typedef int (*mport_confirm_cb)(const char *, const char *, const char *, int); enum _Verbosity{ MPORT_VQUIET, + MPORT_VBRIEF, MPORT_VNORMAL, MPORT_VVERBOSE }; typedef enum _Verbosity mportVerbosity; -mportVerbosity mport_verbosity(bool quiet, bool verbose); +mportVerbosity mport_verbosity(bool quiet, bool verbose, bool brief); typedef struct { int flags; diff --git a/libmport/mport_private.h b/libmport/mport_private.h index 5f7fcee..7854090 100644 --- a/libmport/mport_private.h +++ b/libmport/mport_private.h @@ -51,7 +51,7 @@ #define MPORT_MASTER_VERSION 12 #define MPORT_BUNDLE_VERSION 6 #define MPORT_BUNDLE_VERSION_STR "6" -#define MPORT_VERSION "2.6.3" +#define MPORT_VERSION "2.6.4" #define MPORT_SETTING_MIRROR_REGION "mirror_region" #define MPORT_SETTING_TARGET_OS "target_os" diff --git a/libmport/util.c b/libmport/util.c index ce859bd..aa7a86c 100644 --- a/libmport/util.c +++ b/libmport/util.c @@ -924,13 +924,16 @@ mport_check_answer_bool(char *ans) { } MPORT_PUBLIC_API mportVerbosity -mport_verbosity(bool quiet, bool verbose) { +mport_verbosity(bool quiet, bool verbose, bool brief) { /* if both are specified, we need quiet for backward compatibility */ if (quiet) return (MPORT_VQUIET); + if (brief) + return (MPORT_VBRIEF); + if (verbose) return (MPORT_VVERBOSE); diff --git a/mport/mport.c b/mport/mport.c index 2f32316..3412630 100644 --- a/mport/mport.c +++ b/mport/mport.c @@ -106,10 +106,12 @@ main(int argc, char *argv[]) bool quiet = false; bool verbose = false; bool force = false; + bool brief = false; struct option longopts[] = { { "no-index", no_argument, NULL, 'U' }, { "verbose", no_argument, NULL, 'V' }, + { "brief", no_argument, NULL, 'b'}, { "chroot", required_argument, NULL, 'c' }, { "force", no_argument, NULL, 'f' }, { "output", required_argument, NULL, 'o' }, @@ -126,7 +128,7 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); - while ((ch = getopt_long(argc, argv, "+c:o:fqUVv", longopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "+c:o:bfqUVv", longopts, NULL)) != -1) { switch (ch) { case 'U': noIndex++; @@ -134,6 +136,9 @@ main(int argc, char *argv[]) case 'V': verbose = true; break; + case 'b': + brief = true; + break; case 'c': chroot_path = optarg; break; @@ -165,7 +170,7 @@ main(int argc, char *argv[]) mport = mport_instance_new(); - if (mport_instance_init(mport, NULL, outputPath, noIndex != 0, mport_verbosity(quiet, verbose)) != MPORT_OK) { + if (mport_instance_init(mport, NULL, outputPath, noIndex != 0, mport_verbosity(quiet, verbose, brief)) != MPORT_OK) { errx(1, "%s", mport_err_string()); } mport->force = force;