Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tools/appstreamcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static gboolean optn_explain = FALSE;
static gboolean optn_no_net = FALSE;
static gboolean optn_validate_strict = FALSE;
static gchar *optn_issue_overrides = NULL;
static gboolean optn_ignore_empty = FALSE;

/**
* General options for validation.
Expand Down Expand Up @@ -160,6 +161,13 @@ const GOptionEntry validate_options[] = {
/* TRANSLATORS: ascli flag description for: --override when validating XML files */
N_ ("Override the severities of selected issue tags."),
NULL },
{ "ignore-empty",
(gchar) 0,
0, G_OPTION_ARG_NONE,
&optn_ignore_empty,
/* TRANSLATORS: ascli flag description for: --ignore-empty (used by the "validate" command) */
N_ ("Don't exit with a error when no files are given"),
NULL },

{ NULL }
};
Expand Down Expand Up @@ -477,13 +485,15 @@ as_client_run_validate (const gchar *command, char **argv, int argc)
optn_explain,
optn_validate_strict,
!optn_no_net,
optn_ignore_empty,
optn_issue_overrides);
} else {
return ascli_validate_files_format (&argv[2],
argc - 2,
optn_format,
optn_validate_strict,
!optn_no_net,
optn_ignore_empty,
optn_issue_overrides);
}
}
Expand Down
19 changes: 15 additions & 4 deletions tools/ascli-actions-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ ascli_validate_files (gchar **argv,
gboolean explain,
gboolean validate_strict,
gboolean use_net,
gboolean ignore_empty,
const gchar *overrides_str)
{
gboolean ret = TRUE;
Expand All @@ -392,8 +393,12 @@ ascli_validate_files (gchar **argv,
g_autoptr(GPtrArray) metainfo_files = NULL;

if (argc < 1) {
g_printerr ("%s\n", _("You need to specify at least one file to validate!"));
return ASCLI_EXIT_CODE_FAILED;
if (ignore_empty) {
return ASCLI_EXIT_CODE_SUCCESS;
} else {
g_printerr ("%s\n", _("You need to specify at least one file to validate!"));
return ASCLI_EXIT_CODE_FAILED;
}
}

validator = as_validator_new ();
Expand Down Expand Up @@ -475,6 +480,7 @@ ascli_validate_files_format (gchar **argv,
const gchar *format,
gboolean validate_strict,
gboolean use_net,
gboolean ignore_empty,
const gchar *overrides_str)
{
if (g_strcmp0 (format, "text") == 0) {
Expand All @@ -487,6 +493,7 @@ ascli_validate_files_format (gchar **argv,
TRUE, /* explain */
validate_strict,
use_net,
ignore_empty,
overrides_str);
}

Expand All @@ -496,8 +503,12 @@ ascli_validate_files_format (gchar **argv,
g_autofree gchar *yaml_result = NULL;

if (argc < 1) {
g_print ("%s\n", _("You need to specify at least one file to validate!"));
return 1;
if (ignore_empty) {
return ASCLI_EXIT_CODE_SUCCESS;
} else {
g_print ("%s\n", _("You need to specify at least one file to validate!"));
return ASCLI_EXIT_CODE_FAILED;
}
}

validator = as_validator_new ();
Expand Down
2 changes: 2 additions & 0 deletions tools/ascli-actions-validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ gint ascli_validate_files (gchar **argv,
gboolean pedantic,
gboolean validate_strict,
gboolean use_net,
gboolean ignore_empty,
const gchar *overrides_str);
gint ascli_validate_files_format (gchar **argv,
gint argc,
const gchar *format,
gboolean validate_strict,
gboolean use_net,
gboolean ignore_empty,
const gchar *overrides_str);

gint ascli_validate_tree (const gchar *root_dir,
Expand Down