vsh: Don't translate error messages for 'self-test'

The command invoking the code is internal and meant for developers,
there's no point in translating the errors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2024-03-01 16:39:39 +01:00
parent ea16531d36
commit e1666a088b

View File

@ -255,7 +255,8 @@ vshCmddefGetInfo(const vshCmdDef * cmd, const char *name)
return NULL; return NULL;
} }
/* Check if the internal command definitions are correct */ /* Check if the internal command definitions are correct.
* None of the errors are to be marked as translatable. */
static int static int
vshCmddefCheckInternals(vshControl *ctl, vshCmddefCheckInternals(vshControl *ctl,
const vshCmdDef *cmd, const vshCmdDef *cmd,
@ -271,39 +272,39 @@ vshCmddefCheckInternals(vshControl *ctl,
const vshCmdDef *alias; const vshCmdDef *alias;
if (!cmd->alias) { if (!cmd->alias) {
vshError(ctl, _("command '%1$s' has inconsistent alias"), cmd->name); vshError(ctl, "command '%s' has inconsistent alias", cmd->name);
return -1; return -1;
} }
if (!(alias = vshCmddefSearch(cmd->alias))) { if (!(alias = vshCmddefSearch(cmd->alias))) {
vshError(ctl, _("command alias '%1$s' is pointing to a non-existent command '%2$s'"), vshError(ctl, "command alias '%s' is pointing to a non-existent command '%s'",
cmd->name, cmd->alias); cmd->name, cmd->alias);
return -1; return -1;
} }
if (alias->flags & VSH_CMD_FLAG_ALIAS) { if (alias->flags & VSH_CMD_FLAG_ALIAS) {
vshError(ctl, _("command alias '%1$s' is pointing to another command alias '%2$s'"), vshError(ctl, "command alias '%s' is pointing to another command alias '%s'",
cmd->name, cmd->alias); cmd->name, cmd->alias);
return -1; return -1;
} }
if (cmd->handler) { if (cmd->handler) {
vshError(ctl, _("command '%1$s' has handler set"), cmd->name); vshError(ctl, "command '%s' has handler set", cmd->name);
return -1; return -1;
} }
if (cmd->opts) { if (cmd->opts) {
vshError(ctl, _("command '%1$s' has options set"), cmd->name); vshError(ctl, "command '%s' has options set", cmd->name);
return -1; return -1;
} }
if (cmd->info) { if (cmd->info) {
vshError(ctl, _("command '%1$s' has info set"), cmd->name); vshError(ctl, "command '%s' has info set", cmd->name);
return -1; return -1;
} }
if (cmd->flags & ~VSH_CMD_FLAG_ALIAS) { if (cmd->flags & ~VSH_CMD_FLAG_ALIAS) {
vshError(ctl, _("command '%1$s' has multiple flags set"), cmd->name); vshError(ctl, "command '%s' has multiple flags set", cmd->name);
return -1; return -1;
} }
@ -313,7 +314,7 @@ vshCmddefCheckInternals(vshControl *ctl,
/* Each command has to provide a non-empty help string. */ /* Each command has to provide a non-empty help string. */
if (!(help = vshCmddefGetInfo(cmd, "help")) || !*help) { if (!(help = vshCmddefGetInfo(cmd, "help")) || !*help) {
vshError(ctl, _("command '%1$s' lacks help"), cmd->name); vshError(ctl, "command '%s' lacks help", cmd->name);
return -1; return -1;
} }
@ -324,7 +325,7 @@ vshCmddefCheckInternals(vshControl *ctl,
const vshCmdOptDef *opt = &cmd->opts[i]; const vshCmdOptDef *opt = &cmd->opts[i];
if (i > 63) { if (i > 63) {
vshError(ctl, _("command '%1$s' has too many options"), cmd->name); vshError(ctl, "command '%s' has too many options", cmd->name);
return -1; /* too many options */ return -1; /* too many options */
} }
@ -336,7 +337,7 @@ vshCmddefCheckInternals(vshControl *ctl,
switch (opt->type) { switch (opt->type) {
case VSH_OT_BOOL: case VSH_OT_BOOL:
if (opt->completer || opt->completer_flags) { if (opt->completer || opt->completer_flags) {
vshError(ctl, _("bool parameter '%1$s' of command '%2$s' has completer set"), vshError(ctl, "bool parameter '%s' of command '%s' has completer set",
opt->name, cmd->name); opt->name, cmd->name);
return -1; return -1;
} }
@ -345,7 +346,7 @@ vshCmddefCheckInternals(vshControl *ctl,
case VSH_OT_STRING: case VSH_OT_STRING:
if (opt->flags & VSH_OFLAG_REQ) { if (opt->flags & VSH_OFLAG_REQ) {
vshError(ctl, _("parameter '%1$s' of command '%2$s' misused VSH_OFLAG_REQ"), vshError(ctl, "parameter '%s' of command '%s' misused VSH_OFLAG_REQ",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* neither bool nor string options can be mandatory */ return -1; /* neither bool nor string options can be mandatory */
} }
@ -359,9 +360,9 @@ vshCmddefCheckInternals(vshControl *ctl,
char *p; char *p;
if (opt->flags || !opt->help) { if (opt->flags || !opt->help) {
vshError(ctl, _("parameter '%1$s' of command '%2$s' has incorrect alias option"), vshError(ctl, "parameter '%s' of command '%s' has incorrect alias option",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* alias options are tracked by the original name */ return -1;
} }
if ((p = strchr(opt->help, '='))) if ((p = strchr(opt->help, '=')))
name = g_strndup(opt->help, p - opt->help); name = g_strndup(opt->help, p - opt->help);
@ -375,46 +376,46 @@ vshCmddefCheckInternals(vshControl *ctl,
if (p) { if (p) {
/* If alias comes with value, replacement must not be bool */ /* If alias comes with value, replacement must not be bool */
if (cmd->opts[j].type == VSH_OT_BOOL) { if (cmd->opts[j].type == VSH_OT_BOOL) {
vshError(ctl, _("alias '%1$s' of command '%2$s' has mismatched alias type"), vshError(ctl, "alias '%s' of command '%s' has mismatched alias type",
opt->name, cmd->name); opt->name, cmd->name);
return -1; return -1;
} }
} }
if (!cmd->opts[j].name) { if (!cmd->opts[j].name) {
vshError(ctl, _("alias '%1$s' of command '%2$s' has missing alias option"), vshError(ctl, "alias '%s' of command '%s' has missing alias option",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* alias option must map to a later option name */ return -1;
} }
} }
break; break;
case VSH_OT_ARGV: case VSH_OT_ARGV:
if (cmd->opts[i + 1].name) { if (cmd->opts[i + 1].name) {
vshError(ctl, _("parameter '%1$s' of command '%2$s' must be listed last"), vshError(ctl, "parameter '%s' of command '%s' must be listed last",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* argv option must be listed last */ return -1;
} }
break; break;
case VSH_OT_DATA: case VSH_OT_DATA:
if (!(opt->flags & VSH_OFLAG_REQ)) { if (!(opt->flags & VSH_OFLAG_REQ)) {
vshError(ctl, _("parameter '%1$s' of command '%2$s' must use VSH_OFLAG_REQ flag"), vshError(ctl, "parameter '%s' of command '%s' must use VSH_OFLAG_REQ flag",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* OT_DATA should always be required. */ return -1;
} }
if (seenOptionalOption) { if (seenOptionalOption) {
vshError(ctl, _("parameter '%1$s' of command '%2$s' must be listed before optional parameters"), vshError(ctl, "parameter '%s' of command '%s' must be listed before optional parameters",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* mandatory options must be listed first */ return -1;
} }
break; break;
case VSH_OT_INT: case VSH_OT_INT:
if (opt->flags & VSH_OFLAG_REQ) { if (opt->flags & VSH_OFLAG_REQ) {
if (seenOptionalOption) { if (seenOptionalOption) {
vshError(ctl, _("parameter '%1$s' of command '%2$s' must be listed before optional parameters"), vshError(ctl, "parameter '%s' of command '%s' must be listed before optional parameters",
opt->name, cmd->name); opt->name, cmd->name);
return -1; /* mandatory options must be listed first */ return -1;
} }
} else { } else {
seenOptionalOption = true; seenOptionalOption = true;