Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
And colorize (? too.
  • Loading branch information
jvoisin committed Sep 9, 2014
1 parent 0343c97 commit e4b1246
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
3 changes: 1 addition & 2 deletions libr/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,11 @@ static int cmd_alias(void *data, const char *input) {
char *describe = strchr (buf, '?');
char *v;
if (q) *q = 0;
if (describe) *describe = 0;
v = r_cmd_alias_get (core->rcmd, buf);
if (v) {
if (describe) {
r_cons_printf ("%s\n", v);
free (describe);
free (buf);
return 1;
}
if (q) {
Expand Down
34 changes: 18 additions & 16 deletions libr/core/cmd_macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ static int cmd_macro(void *data, const char *input) {
case '*':
case '\0': r_cmd_macro_list (&core->rcmd->macro); break;
case '(':
case '?':
eprintf (
"|Usage: (foo args,cmd1,cmd2,..)\n"
"| (foo args,..,..) ; define a macro\n"
"| (foo args,..,..)() ; define and call a macro\n"
"| (-foo) ; remove a macro\n"
"| .(foo) ; to call it\n"
"| () ; break inside macro\n"
"| (* ; list all defined macros\n"
"|Argument support:\n"
"| (foo x y\\n$0 @ $1) ; define fun with args\n"
"| .(foo 128 0x804800) ; call it with args\n"
"|Iterations:\n"
"| .(foo\\n() $@) ; define iterator returning iter index\n"
"| x @@ .(foo) ; iterate over them\n"
);
case '?': {
const char* help_msg[] = {
"Usage:", "(foo args,cmd1,cmd2,..)", "Aliases",
"(foo args,..,..)", "", "define a macro",
"(foo args,..,..)()", "", "define and call a macro",
"(-foo)", "", "remove a macro",
".(foo)", "", "to call it",
"()", "", "break inside macro",
"(*", "", "list all defined macros",
"", "Argument support:", "",
"(foo x y\\n$0 @ $1)", "", "define fun with args",
".(foo 128 0x804800)", "", "call it with args",
"", "Iterations:", "",
".(foo\\n() $@)", "", "define iterator returning iter index",
"x @@ .(foo)", "", "iterate over them",
NULL};
r_core_cmd_help (core, help_msg);
}
break;
default: {
// XXX: stop at first ')'. if next is '(' and last
Expand Down

0 comments on commit e4b1246

Please sign in to comment.