mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +01:00
client: Command display functions
This commit is contained in:
parent
17569c8d8b
commit
7c3ed0c61d
@ -29,6 +29,7 @@
|
||||
#include <readline/readline.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "command.h"
|
||||
#include "display.h"
|
||||
|
||||
#define IWD_PROMPT COLOR_GREEN "[iwd]" COLOR_OFF "# "
|
||||
@ -143,6 +144,37 @@ void display_table_footer(void)
|
||||
display_text("\n");
|
||||
}
|
||||
|
||||
void display_command_line(const char *command_family,
|
||||
const struct command *cmd)
|
||||
{
|
||||
char *cmd_line = l_strdup_printf("%s%s%s%s%s %s",
|
||||
command_family ? : "",
|
||||
command_family ? " " : "",
|
||||
cmd->entity ? : "",
|
||||
cmd->entity ? " " : "",
|
||||
cmd->cmd,
|
||||
cmd->arg ? : "",
|
||||
cmd->arg ? " " : "");
|
||||
|
||||
display(MARGIN "%-*s%s\n", 50, cmd_line, cmd->desc ? : "");
|
||||
|
||||
l_free(cmd_line);
|
||||
}
|
||||
|
||||
void display_command(const struct command_family *family, const char *cmd_name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; family->command_list[i].cmd; i++) {
|
||||
if (!strcmp(family->command_list[i].cmd, cmd_name)) {
|
||||
display_command_line(family->name,
|
||||
&family->command_list[i]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void readline_callback(char *prompt)
|
||||
{
|
||||
l_free(prompt);
|
||||
|
@ -20,6 +20,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
struct command;
|
||||
struct command_family;
|
||||
|
||||
#define COLOR_BOLDGRAY "\x1B[1;30m"
|
||||
#define COLOR_GRAY "\x1b[37m"
|
||||
#define COLOR_GREEN "\x1b[32m"
|
||||
@ -33,6 +36,9 @@ void display(const char *format, ...);
|
||||
void display_table_header(const char *caption, const char *fmt, ...);
|
||||
void display_table_footer(void);
|
||||
void display_error(const char *error);
|
||||
void display_command(const struct command_family *family, const char *cmd_name);
|
||||
void display_command_line(const char *command_family,
|
||||
const struct command *cmd);
|
||||
|
||||
void display_enable_cmd_prompt(void);
|
||||
void display_disable_cmd_prompt(void);
|
||||
|
Loading…
Reference in New Issue
Block a user