aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/degesch.c b/degesch.c
index 620e748..38cb9c2 100644
--- a/degesch.c
+++ b/degesch.c
@@ -6830,12 +6830,12 @@ show_aliases_list (struct app_context *ctx)
struct config_item_ *alias;
while ((alias = str_map_iter_next (&iter)))
{
- if (!config_item_type_is_string (alias->type))
- continue;
-
struct str definition;
str_init (&definition);
- config_item_write_string (&definition, &alias->value.string);
+ if (config_item_type_is_string (alias->type))
+ config_item_write_string (&definition, &alias->value.string);
+ else
+ str_append (&definition, "alias definition is not a string");
log_global_indent (ctx, " /#s: #s", iter.link->key, definition.str);
str_free (&definition);
}
@@ -7647,7 +7647,7 @@ static bool
show_command_help (struct app_context *ctx, struct command_handler *handler)
{
log_global_indent (ctx, "");
- log_global_indent (ctx, "#s: #s", handler->name, handler->description);
+ log_global_indent (ctx, "/#s: #s", handler->name, handler->description);
log_global_indent (ctx, " Arguments: #s",
handler->usage ? handler->usage : "(none)");
return true;
@@ -7668,7 +7668,12 @@ handle_command_help (struct handler_args *a)
return show_command_help (ctx, handler);
}
- if (!try_handle_command_help_option (ctx, command))
+ if (try_handle_command_help_option (ctx, command))
+ return true;
+
+ if (str_map_find (get_aliases_config (ctx), command))
+ log_global_status (ctx, "/#s is an alias", command);
+ else
log_global_error (ctx, "#s: #s", "No such command or option", command);
return true;
}
@@ -7786,8 +7791,8 @@ expand_alias (struct app_context *ctx, const char *alias_name, char *input)
if (config_item_type_is_string (entry->type))
return expand_alias_definition (&entry->value.string, input);
- log_global_error (ctx, "Error executing `/%s': "
- "alias definition is not a string", alias_name);
+ log_global_error (ctx, "Error executing `/%s': %s",
+ alias_name, "alias definition is not a string");
return NULL;
}
@@ -7989,7 +7994,6 @@ static void
complete_command (struct app_context *ctx, struct completion *data,
const char *word, struct str_vector *output)
{
- (void) ctx;
(void) data;
const char *prefix = "";
@@ -8007,6 +8011,16 @@ complete_command (struct app_context *ctx, struct completion *data,
str_vector_add_owned (output,
xstrdup_printf ("%s%s", prefix, handler->name));
}
+
+ struct str_map_iter iter;
+ str_map_iter_init (&iter, get_aliases_config (ctx));
+ struct config_item_ *alias;
+ while ((alias = str_map_iter_next (&iter)))
+ {
+ if (!strncasecmp_ascii (word, iter.link->key, word_len))
+ str_vector_add_owned (output,
+ xstrdup_printf ("%s%s", prefix, iter.link->key));
+ }
}
static void