For development, it can be nice to just be able to call a function as-is from the command line. Add a helper to facilitate this. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/command.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/command.h b/include/command.h index 26e06077b071..ae8821969c60 100644 --- a/include/command.h +++ b/include/command.h @@ -119,4 +119,19 @@ static const __maybe_unused char cmd_##_name##_help[] = int register_command(struct command *); +#define DEFINE_SIMPLE_COMMAND(func) \ + struct string_list; \ + int empty_complete(struct string_list *sl, char *instr); \ + static int do_simple_command_##func(int argc, char *argv[]) \ + { \ + func(); \ + return 0; \ + } \ + BAREBOX_CMD_START(func) \ + .cmd = do_simple_command_##func, \ + BAREBOX_CMD_DESC("call " # func "()") \ + BAREBOX_CMD_GROUP(CMD_GRP_INFO) \ + BAREBOX_CMD_COMPLETE(empty_complete) \ + BAREBOX_CMD_END + #endif /* __COMMAND_H */ -- 2.39.5