diff --git a/kubo_command.c b/kubo_command.c index 2543163..68eae67 100644 --- a/kubo_command.c +++ b/kubo_command.c @@ -20,9 +20,12 @@ static inline void kubo_command_exit(struct kubo_context *context, char *rest); static inline void kubo_command_write(struct kubo_context *context, char *rest); +static inline void kubo_command_read(struct kubo_context *context, char *rest); static const struct kubo_command_data kubo_commands[] = { - {":q", kubo_command_exit}, {":w", kubo_command_write}}; + {":q", kubo_command_exit}, + {":w", kubo_command_write}, + {":e", kubo_command_read}}; static const size_t kubo_commands_size = sizeof(kubo_commands) / sizeof(kubo_commands[0]); @@ -63,10 +66,21 @@ static inline void kubo_command_exit(struct kubo_context *context, char *rest) { context->exit_pending = true; } -static inline void kubo_command_write(struct kubo_context *context, char *rest) { +static inline void kubo_command_write(struct kubo_context *context, + char *rest) { if (rest) { context->file_name = rest; } kubo_file_write(context); } + +static inline void kubo_command_read(struct kubo_context *context, char *rest) { + if (rest) { + context->file_name = rest; + } else { + return; + } + + *context = kubo_file_parse(rest); +}