14#include "common/lang/string_view.h"
20#define DEFINE_OBLSM_CLI_CMDS \
21 DEFINE_OBLSM_CLI_CMD( \
22 OPEN, "open", "Usage: open \"DATABASE_NAME\"\nOpens a database. If the database does not exist, it is created.") \
23 DEFINE_OBLSM_CLI_CMD(CLOSE, "close", "Usage: close\nCloses the currently opened database.") \
24 DEFINE_OBLSM_CLI_CMD(SET, "set", "Usage: set \"KEY\" \"VALUE\"\nSets the value for the given key.") \
25 DEFINE_OBLSM_CLI_CMD(GET, "get", "Usage: get \"KEY\"\nGets the value associated with the given key.") \
26 DEFINE_OBLSM_CLI_CMD(DELETE, "delete", "Usage: delete \"KEY\"\nDeletes the given key.") \
27 DEFINE_OBLSM_CLI_CMD(SCAN, \
29 "Usage: scan \"KEY1\" \"KEY2\"\n" \
30 "Scans the database for keys within the specified range.\n" \
31 "The first and second keys can be specified in the following ways:\n" \
32 "- 'scan - \"KEY\"' scans from the first key in the database up to the specified key \"KEY\".\n" \
33 "- 'scan \"KEY\" -' scans from the specified key \"KEY\" to the last key in the database.\n" \
34 "- 'scan - -' scans the entire database from the first key to the last key.\n" \
35 "- 'scan \"KEY1\" \"KEY2\"' scans from the key \"KEY1\" to the key \"KEY2\".\n") \
36 DEFINE_OBLSM_CLI_CMD(HELP, "help", "") \
37 DEFINE_OBLSM_CLI_CMD(EXIT, "exit", "Usage: exit\nExits the application.")
39enum class ObLsmCliCmdType
41#define DEFINE_OBLSM_CLI_CMD(cmd, str, help) cmd,
43#undef DEFINE_OBLSM_CLI_CMD
49 inline static const string_view strcmd(ObLsmCliCmdType command)
51#define DEFINE_OBLSM_CLI_CMD(cmd, name, help) \
52 case ObLsmCliCmdType::cmd: { \
57 DEFINE_OBLSM_CLI_CMDS;
63#undef DEFINE_OBLSM_CLI_CMD
66 inline static const string_view cmd_usage(ObLsmCliCmdType command)
68#define DEFINE_OBLSM_CLI_CMD(cmd, name, help) \
69 case ObLsmCliCmdType::cmd: { \
74 DEFINE_OBLSM_CLI_CMDS;
76 return "Unknown command usage.";
80#undef DEFINE_OBLSM_CLI_CMD