Moved help message to config
This commit is contained in:
parent
99871ddc73
commit
4df151ea85
@ -1,9 +1,42 @@
|
|||||||
pub const BUFFER_SIZE = 1024 * 50; // Line limit when parsing file
|
pub const BUFFER_SIZE = 1024 * 50; // Line limit when parsing file
|
||||||
pub const MAX_FILE_SIZE = 5e+4; // 50kb TODO: Put in config file
|
pub const MAX_FILE_SIZE = 5e+6; // 5Mb
|
||||||
pub const CSV_DELIMITER = ';';
|
pub const CSV_DELIMITER = ';'; // TODO: Delete
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
pub const TEST_DATA_DIR = "test_data/v0.1.2"; // Maybe put that directly in the build
|
pub const TEST_DATA_DIR = "test_data/v0.1.2"; // Maybe put that directly in the build
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
pub const DONT_SEND = true;
|
pub const DONT_SEND = true;
|
||||||
|
|
||||||
|
// Help message
|
||||||
|
pub const HELP_MESSAGE = struct {
|
||||||
|
pub const main: []const u8 =
|
||||||
|
\\Welcome to ZipponDB v0.1.1!
|
||||||
|
\\
|
||||||
|
\\Available commands:
|
||||||
|
\\run To run a query.
|
||||||
|
\\db Create or chose a database.
|
||||||
|
\\schema Initialize the database schema.
|
||||||
|
\\quit Stop the CLI with memory safety.
|
||||||
|
\\
|
||||||
|
\\For more informations: https://github.com/MrBounty/ZipponDB
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
pub const db: []const u8 =
|
||||||
|
\\Available commands:
|
||||||
|
\\new Create a new database using a path to a sub folder.
|
||||||
|
\\use Select another ZipponDB folder to use as database.
|
||||||
|
\\metrics Print some metrics of the current database.
|
||||||
|
\\
|
||||||
|
\\For more informations: https://github.com/MrBounty/ZipponDB
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
pub const schema: []const u8 =
|
||||||
|
\\Available commands:
|
||||||
|
\\describe Print the schema use by the currently selected database.
|
||||||
|
\\init Take the path to a schema file and initialize the database.
|
||||||
|
\\
|
||||||
|
\\For more informations: https://github.com/MrBounty/ZipponDB
|
||||||
|
\\
|
||||||
|
;
|
||||||
|
};
|
||||||
|
33
src/main.zig
33
src/main.zig
@ -13,6 +13,7 @@ const utils = @import("stuffs/utils.zig");
|
|||||||
const send = @import("stuffs/utils.zig").send;
|
const send = @import("stuffs/utils.zig").send;
|
||||||
|
|
||||||
const BUFFER_SIZE = @import("config.zig").BUFFER_SIZE;
|
const BUFFER_SIZE = @import("config.zig").BUFFER_SIZE;
|
||||||
|
const HELP_MESSAGE = @import("config.zig").HELP_MESSAGE;
|
||||||
|
|
||||||
const State = enum {
|
const State = enum {
|
||||||
expect_main_command,
|
expect_main_command,
|
||||||
@ -119,18 +120,7 @@ pub fn main() !void {
|
|||||||
state = .expect_schema_command;
|
state = .expect_schema_command;
|
||||||
},
|
},
|
||||||
.keyword_help => {
|
.keyword_help => {
|
||||||
send("{s}", .{
|
send("{s}", .{HELP_MESSAGE.main});
|
||||||
\\Welcome to ZipponDB v0.1.1!
|
|
||||||
\\
|
|
||||||
\\Available commands:
|
|
||||||
\\run To run a query.
|
|
||||||
\\db Create or chose a database.
|
|
||||||
\\schema Initialize the database schema.
|
|
||||||
\\quit Stop the CLI with memory safety.
|
|
||||||
\\
|
|
||||||
\\ For more informations: https://github.com/MrBounty/ZipponDB
|
|
||||||
\\
|
|
||||||
});
|
|
||||||
state = .end;
|
state = .end;
|
||||||
},
|
},
|
||||||
.keyword_quit => state = .quit,
|
.keyword_quit => state = .quit,
|
||||||
@ -159,15 +149,7 @@ pub fn main() !void {
|
|||||||
state = .end;
|
state = .end;
|
||||||
},
|
},
|
||||||
.keyword_help => {
|
.keyword_help => {
|
||||||
send("{s}", .{
|
send("{s}", .{HELP_MESSAGE.db});
|
||||||
\\Available commands:
|
|
||||||
\\new Create a new database using a path to a sub folder.
|
|
||||||
\\use Select another ZipponDB folder to use as database.
|
|
||||||
\\metrics Print some metrics of the current database.
|
|
||||||
\\
|
|
||||||
\\ For more informations: https://github.com/MrBounty/ZipponDB
|
|
||||||
\\
|
|
||||||
});
|
|
||||||
state = .end;
|
state = .end;
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
@ -237,14 +219,7 @@ pub fn main() !void {
|
|||||||
},
|
},
|
||||||
.keyword_init => state = .expect_path_to_schema,
|
.keyword_init => state = .expect_path_to_schema,
|
||||||
.keyword_help => {
|
.keyword_help => {
|
||||||
send("{s}", .{
|
send("{s}", .{HELP_MESSAGE.schema});
|
||||||
\\Available commands:
|
|
||||||
\\describe Print the schema use by the currently selected database.
|
|
||||||
\\init Take the path to a schema file and initialize the database.
|
|
||||||
\\
|
|
||||||
\\ For more informations: https://github.com/MrBounty/ZipponDB
|
|
||||||
\\
|
|
||||||
});
|
|
||||||
state = .end;
|
state = .end;
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user