+ .name = "type",
+ .mode = COMMAND_ANY,
+ .jim_handler = jim_command_type,
+ .usage = "command_name [...]",
+ .help = "Returns the type of built-in command:"
+ "'native', 'simple', 'group', or 'unknown'. "
+ "Command can be multiple tokens.",
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+static const struct command_registration command_builtin_handlers[] = {
+ {
+ .name = "echo",
+ .handler = jim_echo,
+ .mode = COMMAND_ANY,
+ .help = "Logs a message at \"user\" priority. "
+ "Output message to stdout. "
+ "Option \"-n\" suppresses trailing newline",
+ .usage = "[-n] string",
+ },
+ {
+ .name = "add_help_text",
+ .handler = handle_help_add_command,
+ .mode = COMMAND_ANY,
+ .help = "Add new command help text; "
+ "Command can be multiple tokens.",
+ .usage = "command_name helptext_string",
+ },
+ {
+ .name = "add_usage_text",
+ .handler = handle_help_add_command,
+ .mode = COMMAND_ANY,
+ .help = "Add new command usage text; "
+ "command can be multiple tokens.",
+ .usage = "command_name usage_string",
+ },
+ {
+ .name = "sleep",
+ .handler = handle_sleep_command,
+ .mode = COMMAND_ANY,
+ .help = "Sleep for specified number of milliseconds. "
+ "\"busy\" will busy wait instead (avoid this).",
+ .usage = "milliseconds ['busy']",
+ },
+ {
+ .name = "help",
+ .handler = handle_help_command,
+ .mode = COMMAND_ANY,
+ .help = "Show full command help; "
+ "command can be multiple tokens.",
+ .usage = "[command_name]",
+ },
+ {
+ .name = "usage",
+ .handler = handle_help_command,
+ .mode = COMMAND_ANY,
+ .help = "Show basic command usage; "
+ "command can be multiple tokens.",
+ .usage = "[command_name]",
+ },
+ {
+ .name = "command",
+ .mode = COMMAND_ANY,
+ .help = "core command group (introspection)",
+ .chain = command_subcommand_handlers,
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+struct command_context *command_init(const char *startup_tcl, Jim_Interp *interp)
+{
+ struct command_context *context = calloc(1, sizeof(struct command_context));
+ const char *HostOs;
+
+ context->mode = COMMAND_EXEC;
+
+ /* Create a jim interpreter if we were not handed one */
+ if (interp == NULL) {
+ /* Create an interpreter */
+ interp = Jim_CreateInterp();
+ /* Add all the Jim core commands */
+ Jim_RegisterCoreCommands(interp);
+ Jim_InitStaticExtensions(interp);