add command completion to "flashmem", "endian", and "readmem"

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1893 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent 80d68a944c
commit 75f7b98334

@ -13,6 +13,10 @@
from an earlier commit -- make sure the literal "signal" is the 2nd arg in
the help text and for completion handlers.
* src/cmd/cmd_flashmem.c: Add a completion handler.
* src/cmd/cmd_endian.c: Likewise.
* src/cmd/cmd_readmem.c: Likewise.
2011-02-21 Mike Frysinger <vapier@gentoo.org>
* data/Makefile.am (nobase_dist_pkgdata_DATA): Add missing analog/bfin/bfin.

@ -121,9 +121,21 @@ cmd_endian_help (void)
"endian [little|big]");
}
static void
cmd_endian_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
{
if (token_point != 1)
return;
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "big");
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "little");
}
const urj_cmd_t urj_cmd_endian = {
"endian",
N_("set/print endianess"),
cmd_endian_help,
cmd_endian_run
cmd_endian_run,
cmd_endian_complete,
};

@ -29,6 +29,10 @@
#include <string.h>
#include <errno.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#endif
#include <urjtag/error.h>
#include <urjtag/bus.h>
#include <urjtag/flash.h>
@ -108,9 +112,44 @@ cmd_flashmem_help (void)
urj_cmd_show_list (urj_flash_flash_drivers);
}
static void
cmd_flashmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
{
switch (token_point)
{
case 1: /* [addr|msbin] */
break;
case 2: /* filename */
{
#ifdef HAVE_LIBREADLINE
int state;
char *match;
state = 0;
while (1)
{
match = rl_filename_completion_function (text, state++);
if (!match)
break;
urj_completion_add_match_dupe (matches, match_cnt, match);
free (match);
}
#endif
break;
}
case 3: /* [noverify] */
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "noverify");
break;
}
}
const urj_cmd_t urj_cmd_flashmem = {
"flashmem",
N_("burn flash memory with data from a file"),
cmd_flashmem_help,
cmd_flashmem_run
cmd_flashmem_run,
cmd_flashmem_complete,
};

@ -29,6 +29,10 @@
#include <string.h>
#include <errno.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#endif
#include <urjtag/error.h>
#include <urjtag/bus.h>
@ -89,9 +93,43 @@ cmd_readmem_help (void)
"readmem");
}
static void
cmd_readmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
const char *text, size_t text_len, size_t token_point)
{
switch (token_point)
{
case 1: /* addr */
break;
case 2: /* len */
break;
case 3: /* filename */
{
#ifdef HAVE_LIBREADLINE
int state;
char *match;
state = 0;
while (1)
{
match = rl_filename_completion_function (text, state++);
if (!match)
break;
urj_completion_add_match_dupe (matches, match_cnt, match);
free (match);
}
#endif
break;
}
}
}
const urj_cmd_t urj_cmd_readmem = {
"readmem",
N_("read content of the memory and write it to file"),
cmd_readmem_help,
cmd_readmem_run
cmd_readmem_run,
cmd_readmem_complete,
};

Loading…
Cancel
Save