From 4df151ea853e7c552893eafc505ec4774d9df0ce Mon Sep 17 00:00:00 2001 From: MrBounty Date: Sun, 27 Oct 2024 11:20:02 +0100 Subject: [PATCH] Moved help message to config --- src/config.zig | 37 +++++++++++++++++++++++++++++++++++-- src/main.zig | 33 ++++----------------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/config.zig b/src/config.zig index d649f77..3234703 100644 --- a/src/config.zig +++ b/src/config.zig @@ -1,9 +1,42 @@ 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 CSV_DELIMITER = ';'; +pub const MAX_FILE_SIZE = 5e+6; // 5Mb +pub const CSV_DELIMITER = ';'; // TODO: Delete // Testing pub const TEST_DATA_DIR = "test_data/v0.1.2"; // Maybe put that directly in the build // Debug 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 + \\ + ; +}; diff --git a/src/main.zig b/src/main.zig index 85ee8d3..fd8b3ad 100644 --- a/src/main.zig +++ b/src/main.zig @@ -13,6 +13,7 @@ const utils = @import("stuffs/utils.zig"); const send = @import("stuffs/utils.zig").send; const BUFFER_SIZE = @import("config.zig").BUFFER_SIZE; +const HELP_MESSAGE = @import("config.zig").HELP_MESSAGE; const State = enum { expect_main_command, @@ -119,18 +120,7 @@ pub fn main() !void { state = .expect_schema_command; }, .keyword_help => { - send("{s}", .{ - \\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 - \\ - }); + send("{s}", .{HELP_MESSAGE.main}); state = .end; }, .keyword_quit => state = .quit, @@ -159,15 +149,7 @@ pub fn main() !void { state = .end; }, .keyword_help => { - send("{s}", .{ - \\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 - \\ - }); + send("{s}", .{HELP_MESSAGE.db}); state = .end; }, else => { @@ -237,14 +219,7 @@ pub fn main() !void { }, .keyword_init => state = .expect_path_to_schema, .keyword_help => { - send("{s}", .{ - \\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 - \\ - }); + send("{s}", .{HELP_MESSAGE.schema}); state = .end; }, else => {