Skip to content

Commit 9392780

Browse files
small changes
1 parent ac1efaf commit 9392780

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

code/logic/app.c

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

19-
20-
void show_commands(void) {
21-
fossil_io_printf("{blue}Usage: fossil_app [OPTIONS]{reset}\n");
17+
void show_commands(char* app_name) {
18+
fossil_io_printf("{blue}Usage: {cyan}%s{blue} <options>{reset}\n", app_name);
2219
fossil_io_printf("{cyan} --help Show this help message{reset}\n");
2320
fossil_io_printf("{cyan} --version Show version information{reset}\n");
2421
fossil_io_printf("{cyan} color Enable colored output ({yellow}'enable'/disable/auto{cyan}){reset}\n");
25-
exit(0);
22+
exit(FOSSIL_IO_SUCCESS);
2623
}
2724

2825
void show_version(void) {
2926
fossil_io_printf("{blue}%s version %s{reset}\n", FOSSIL_APP_NAME, FOSSIL_APP_VERSION);
30-
exit(0);
27+
exit(FOSSIL_IO_SUCCESS);
3128
}
3229

3330
bool app_entry(int argc, char** argv) {
34-
for (int i = 1; i < argc; ++i) {
35-
if (argv[i] == NULL) continue;
36-
if (strcmp(argv[i], "--help") == 0) {
37-
show_commands();
38-
} else if (strcmp(argv[i], "--version") == 0) {
31+
for (u32 i = 1; i < argc; ++i) {
32+
if (argv[i] == cnullptr) continue;
33+
if (fossil_io_cstring_compare(argv[i], "--help") == 0) {
34+
show_commands(argv[0]);
35+
} else if (fossil_io_cstring_compare(argv[i], "--version") == 0) {
3936
show_version();
40-
} else if (strcmp(argv[i], "color") == 0) {
41-
if (i + 1 < argc && argv[i + 1] != NULL) {
42-
if (strcmp(argv[i + 1], "enable") == 0) {
37+
} else if (fossil_io_cstring_compare(argv[i], "color") == 0) {
38+
if (i + 1 < argc && argv[i + 1] != cnullptr) {
39+
if (fossil_io_cstring_compare(argv[i + 1], "enable") == 0) {
4340
FOSSIL_IO_COLOR_ENABLE = true;
44-
} else if (strcmp(argv[i + 1], "disable") == 0) {
41+
} else if (fossil_io_cstring_compare(argv[i + 1], "disable") == 0) {
4542
FOSSIL_IO_COLOR_ENABLE = false;
46-
} else if (strcmp(argv[i + 1], "auto") == 0) {
43+
} else if (fossil_io_cstring_compare(argv[i + 1], "auto") == 0) {
4744
FOSSIL_IO_COLOR_ENABLE = isatty(STDOUT_FILENO);
4845
}
4946
++i; // Skip next argument

0 commit comments

Comments
 (0)