add command completion support to more commands

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1964 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 13 years ago
parent 0d1b7f7a12
commit 424f2ec225

@ -8,6 +8,10 @@
* src/cmd/cmd_part.c (cmd_part_help): Update output to reflect reality.
* src/cmd/cmd_bsdl.c, src/cmd/cmd_bus.c, src/cmd/cmd_dr.c,
src/cmd/cmd_part.c, src/cmd/cmd_pod.c, src/cmd/cmd_shell.c,
src/cmd/cmd_svf.c, src/cmd/cmd_writemem.c: Add completion handlers.
2011-07-06 Jie Zhang <jie.zhang@analog.com>
* src/tap/chain.c (urj_tap_chain_connect): Correct checking of the

@ -116,6 +116,40 @@ cmd_bsdl_run (urj_chain_t *chain, char *params[])
return (result >= 0) ? URJ_STATUS_OK : URJ_STATUS_FAIL;
}
static void
cmd_bsdl_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
static const char * const main_cmds[] = {
"path",
"test",
"dump",
"debug",
};
static const char * const debug_cmds[] = {
"on", "off",
};
switch (token_point)
{
case 1:
urj_completion_mayben_add_matches (matches, match_cnt, text, text_len,
main_cmds);
break;
case 2:
/* XXX: For "test" and "dump", we'll want to search the bsdl paths */
if (!strcmp (tokens[1], "path"))
urj_completion_mayben_add_file (matches, match_cnt, text,
text_len, false);
else if (!strcmp (tokens[1], "debug"))
urj_completion_mayben_add_matches (matches, match_cnt, text,
text_len, debug_cmds);
break;
}
}
static void
cmd_bsdl_help (void)
@ -136,7 +170,8 @@ const urj_cmd_t urj_cmd_bsdl = {
"bsdl",
N_("manage BSDL files"),
cmd_bsdl_help,
cmd_bsdl_run
cmd_bsdl_run,
cmd_bsdl_complete,
};

@ -64,6 +64,27 @@ cmd_bus_run (urj_chain_t *chain, char *params[])
return urj_bus_buses_set (n);
}
static void
cmd_bus_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
int i;
if (token_point != 1)
return;
for (i = 0; i < urj_buses.len; ++i)
{
/* We assume you'll never have more than 15*10 buses */
char num[16];
sprintf (num, "%i", i);
urj_completion_mayben_add_match (matches, match_cnt, text,
text_len, num);
}
}
static void
cmd_bus_help (void)
{
@ -78,5 +99,6 @@ const urj_cmd_t urj_cmd_bus = {
"bus",
N_("change active bus"),
cmd_bus_help,
cmd_bus_run
cmd_bus_run,
cmd_bus_complete,
};

@ -104,6 +104,22 @@ cmd_dr_run (urj_chain_t *chain, char *params[])
return URJ_STATUS_OK;
}
static void
cmd_dr_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
static const char * const dir[] = {
"in",
"out",
};
if (token_point != 1)
return;
urj_completion_mayben_add_matches (matches, match_cnt, text, text_len, dir);
}
static void
cmd_dr_help (void)
{
@ -124,5 +140,6 @@ const urj_cmd_t urj_cmd_dr = {
"dr",
N_("display active data register for a part"),
cmd_dr_help,
cmd_dr_run
cmd_dr_run,
cmd_dr_complete,
};

@ -126,6 +126,33 @@ cmd_part_run (urj_chain_t *chain, char *params[])
return URJ_STATUS_OK;
}
static void
cmd_part_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
int i;
if (token_point != 1)
return;
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "alias");
for (i = 0; i < chain->parts->len; ++i)
{
/* We assume you'll never have more than 15*10 parts */
char num[16];
sprintf (num, "%i", i);
urj_completion_mayben_add_match (matches, match_cnt, text,
text_len, num);
if (chain->parts->parts[i]->alias)
urj_completion_mayben_add_match (matches, match_cnt, text, text_len,
chain->parts->parts[i]->alias);
}
}
static void
cmd_part_help (void)
{
@ -141,5 +168,6 @@ const urj_cmd_t urj_cmd_part = {
"part",
N_("change active part for current JTAG chain"),
cmd_part_help,
cmd_part_run
cmd_part_run,
cmd_part_complete,
};

@ -98,6 +98,23 @@ cmd_pod_run (urj_chain_t *chain, char *params[])
return URJ_STATUS_OK;
}
static void
cmd_pod_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
static const char * const signals[] = {
"TCK=",
"TMS=",
"TDI=",
"TRST=",
"RESET=",
};
urj_completion_mayben_add_matches (matches, match_cnt, text,
text_len, signals);
}
static void
cmd_pod_help (void)
{
@ -114,5 +131,6 @@ const urj_cmd_t urj_cmd_pod = {
"pod",
N_("Set state of POD signal(s)"),
cmd_pod_help,
cmd_pod_run
cmd_pod_run,
cmd_pod_complete,
};

@ -88,6 +88,15 @@ cmd_shell_run (urj_chain_t *chain, char *params[])
return URJ_STATUS_OK;
}
static void
cmd_shell_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
/* XXX: Should first token complete via $PATH ? */
urj_completion_mayben_add_file (matches, match_cnt, text, text_len, false);
}
static void
cmd_shell_help (void)
{
@ -102,5 +111,6 @@ const urj_cmd_t urj_cmd_shell = {
"shell",
N_("run a shell command"),
cmd_shell_help,
cmd_shell_run
cmd_shell_run,
cmd_shell_complete,
};

@ -95,6 +95,30 @@ cmd_svf_run (urj_chain_t *chain, char *params[])
return result;
}
static void
cmd_svf_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
static const char * const main_cmds[] = {
"stop",
"progress",
"ref_freq=",
};
switch (token_point)
{
case 1:
urj_completion_mayben_add_file (matches, match_cnt, text,
text_len, false);
break;
default:
urj_completion_mayben_add_matches (matches, match_cnt, text, text_len,
main_cmds);
break;
}
}
static void
cmd_svf_help (void)
@ -113,5 +137,6 @@ const urj_cmd_t urj_cmd_svf = {
"svf",
N_("execute svf commands from file"),
cmd_svf_help,
cmd_svf_run
cmd_svf_run,
cmd_svf_complete,
};

@ -72,6 +72,24 @@ cmd_writemem_run (urj_chain_t *chain, char *params[])
return r;
}
static void
cmd_writemem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
switch (token_point)
{
case 1: /* addr */
case 2: /* len */
break;
case 3: /* filename */
urj_completion_mayben_add_file (matches, match_cnt, text,
text_len, false);
break;
}
}
static void
cmd_writemem_help (void)
{
@ -92,5 +110,6 @@ const urj_cmd_t urj_cmd_writemem = {
"writemem",
N_("write content of file to the memory"),
cmd_writemem_help,
cmd_writemem_run
cmd_writemem_run,
cmd_writemem_complete,
};

Loading…
Cancel
Save