Skip to content

Commit ac1efaf

Browse files
prefer command pallet
1 parent 5d58536 commit ac1efaf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

code/logic/app.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,32 @@
1313
*/
1414
#include "fossil/code/app.h"
1515
#include <unistd.h>
16+
#include <string.h>
17+
#include <stdbool.h>
1618

1719

18-
void show_commands() {
19-
printf("Usage: fossil_app [OPTIONS]\n");
20-
printf(" --help Show this help message\n");
21-
printf(" --version Show version information\n");
22-
printf(" color Enable colored output ('enable'/disable/auto)\n");
20+
void show_commands(void) {
21+
fossil_io_printf("{blue}Usage: fossil_app [OPTIONS]{reset}\n");
22+
fossil_io_printf("{cyan} --help Show this help message{reset}\n");
23+
fossil_io_printf("{cyan} --version Show version information{reset}\n");
24+
fossil_io_printf("{cyan} color Enable colored output ({yellow}'enable'/disable/auto{cyan}){reset}\n");
2325
exit(0);
2426
}
2527

26-
void show_version() {
27-
printf("%s version %s\n", FOSSIL_APP_NAME, FOSSIL_APP_VERSION);
28+
void show_version(void) {
29+
fossil_io_printf("{blue}%s version %s{reset}\n", FOSSIL_APP_NAME, FOSSIL_APP_VERSION);
2830
exit(0);
2931
}
3032

3133
bool app_entry(int argc, char** argv) {
32-
bool color_enabled = false;
3334
for (int i = 1; i < argc; ++i) {
35+
if (argv[i] == NULL) continue;
3436
if (strcmp(argv[i], "--help") == 0) {
3537
show_commands();
3638
} else if (strcmp(argv[i], "--version") == 0) {
3739
show_version();
3840
} else if (strcmp(argv[i], "color") == 0) {
39-
if (i + 1 < argc) {
41+
if (i + 1 < argc && argv[i + 1] != NULL) {
4042
if (strcmp(argv[i + 1], "enable") == 0) {
4143
FOSSIL_IO_COLOR_ENABLE = true;
4244
} else if (strcmp(argv[i + 1], "disable") == 0) {
@@ -48,6 +50,5 @@ bool app_entry(int argc, char** argv) {
4850
}
4951
}
5052
}
51-
5253
return 0;
5354
}

0 commit comments

Comments
 (0)