From 5f068ebcc05703ac7e4f1051fbe5eaf21f0d7f75 Mon Sep 17 00:00:00 2001 From: Anser Date: Sun, 16 Aug 2026 23:18:06 +0200 Subject: added new ascii art. added a simple helper menu with flags -v -h --- src/ascii.c | 5 ++++- src/cfetch.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ascii.c b/src/ascii.c index f1365db..328ec7f 100644 --- a/src/ascii.c +++ b/src/ascii.c @@ -19,13 +19,16 @@ #include #include -#define MAX_LOGOS 2 +#define MAX_LOGOS 5 static const struct ascii_mapping_t ascii_mappings[] = { {"cccp", "cccp.ascii"}, {"cccp_shield", "cccp_shield.ascii"}, + {"ascii_hammer", "ascii_hammer.ascii"}, + {"east_germany", "east_germany.ascii"}, + {"soviet_star", "soviet_star.ascii"}, {NULL, NULL} }; diff --git a/src/cfetch.c b/src/cfetch.c index fd53ae5..c0ea8ab 100644 --- a/src/cfetch.c +++ b/src/cfetch.c @@ -24,12 +24,21 @@ #include #include +#define COMMAND(large, small) \ + (!strcmp(argv[i], large) || !strcmp(argv[i], small)) + +void parse_args(int argc, char** argv); +void print_help(); + +int main(int argc, char **argv) +{ + parse_args(argc, argv); + -int main(void) { struct system_info_t info = { 0 }; //info.debug = 1; // set default artwork - info.ascii_art = 0; + info.ascii_art = 3; // set systeminformation // use // to uncomment or comment @@ -54,3 +63,51 @@ int main(void) { get_gpu get_colours ? */ + +void parse_cmd(int argc, char **argv) +{ + for (int i = 1; i < argc; i++) { + if (argv[i][0] != '-') + { + fprintf(stderr, + "Error: invalid option: \"%s\". An option must start with `-`\n", + argv[i]); + print_help(); + exit(1); + } + if (COMMAND("--help", "-h")) { + print_help(); + exit(1); + } + if (COMMAND("--version", "-v")) { + printf("cfetch version: 0.1.1\n"); + exit(0); + } else { + fprintf(stderr, + "Error: invalid option: \"%s\"\n", + argv[i]); + print_help(); + exit(1); + } + } + + return; +} + +void parse_args(int argc, char **argv) +{ + if (argc == 1) { + return; + } + + parse_cmd(argc, argv); + return; +} + +void print_help() +{ + printf("\ncfetch, the neofetch/commifetch clone!\n"); + printf("\nusage: cfetch\t [-v | --version] [-h | --help]\n"); + printf(" -v --version\t prints the current version of cfetch.\n"); + printf(" -h --help\t prints the helper menu of cfetch.\n"); +} -- cgit v1.2.3