Skip to content

Commit

Permalink
Abstracted away all CLI msgs through sk_text module
Browse files Browse the repository at this point in the history
Also added the license notice at the top of the files that didn't had it
  • Loading branch information
iWas-Coder committed Apr 2, 2024
1 parent 4c35124 commit 649ad78
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 11 deletions.
21 changes: 21 additions & 0 deletions include/sk_launcher.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
* GNU Sparky --- A 5v5 character-based libre tactical shooter
* Copyright (C) 2024 Wasym A. Alonso
*
* This file is part of Sparky.
*
* Sparky is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sparky is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Sparky. If not, see <http://www.gnu.org/licenses/>.
*/


#pragma once

void sk_launcher_run(void);
8 changes: 8 additions & 0 deletions include/sk_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#pragma once

#include <sk_defines.h>

static const char * const sk_text_help_msg = "Usage: %s [OPTION]\n"
"GNU Sparky --- A 5v5 character-based libre tactical shooter\n\n"
"If no option is provided, the client will start in offline mode.\n\n"
Expand All @@ -43,3 +45,9 @@ static const char * const sk_text_version_msg = "GNU Sparky %s\n"

static const char * const sk_text_unrecog_opt_msg = "%s: unrecognized option\n"
"Try '%s --help' for more information.\n";

u8 sk_text_help(char *prog_name);

u8 sk_text_version(void);

u8 sk_text_unrecog_opt(char *prog_name);
21 changes: 21 additions & 0 deletions src/sk_launcher.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
* GNU Sparky --- A 5v5 character-based libre tactical shooter
* Copyright (C) 2024 Wasym A. Alonso
*
* This file is part of Sparky.
*
* Sparky is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sparky is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Sparky. If not, see <http://www.gnu.org/licenses/>.
*/


use eframe::egui;
extern crate eframe;

Expand Down
38 changes: 38 additions & 0 deletions src/sk_text.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* GNU Sparky --- A 5v5 character-based libre tactical shooter
* Copyright (C) 2024 Wasym A. Alonso
*
* This file is part of Sparky.
*
* Sparky is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sparky is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Sparky. If not, see <http://www.gnu.org/licenses/>.
*/


#include <stdio.h>
#include <sk_text.h>

u8 sk_text_help(char *prog_name) {
printf(sk_text_help_msg, prog_name);
return 0;
}

u8 sk_text_version(void) {
printf(sk_text_version_msg, sk_xstr(SK_VERSION));
return 0;
}

u8 sk_text_unrecog_opt(char *prog_name) {
fprintf(stderr, sk_text_unrecog_opt_msg, prog_name, prog_name);
return 1;
}
14 changes: 3 additions & 11 deletions src/sparky.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/


#include <stdio.h>
#include <string.h>
#include <sk_log.h>
#include <sk_text.h>
Expand All @@ -40,15 +39,8 @@ int main(int argc, char **argv) {
}
if (argc == 3 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--ip"))) return sk_client_run(argv[2]);
if (argc == 2 && (!strcmp(argv[1], "-s") || !strcmp(argv[1], "--server"))) return sk_server_run();
if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
printf(sk_text_help_msg, argv[0]);
return 0;
}
if (argc == 2 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
printf(sk_text_version_msg, sk_xstr(SK_VERSION));
return 0;
}
if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) return sk_text_help(argv[0]);
if (argc == 2 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) return sk_text_version();

fprintf(stderr, sk_text_unrecog_opt_msg, argv[0], argv[0]);
return 1;
return sk_text_unrecog_opt(argv[0]);
}

0 comments on commit 649ad78

Please sign in to comment.