Skip to content

Commit

Permalink
Add support for brief for mport.list
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Aug 12, 2024
1 parent ab375ab commit 5daca6e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libexec/mport.info/mport.info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions libexec/mport.list/mport.list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions libmport/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion libmport/mport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libmport/mport_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion libmport/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 7 additions & 2 deletions mport/mport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -126,14 +128,17 @@ 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++;
break;
case 'V':
verbose = true;
break;
case 'b':
brief = true;
break;
case 'c':
chroot_path = optarg;
break;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5daca6e

Please sign in to comment.