diff options
| author | Anser <rostgans@tutamail.com> | 2026-08-16 23:18:06 +0200 |
|---|---|---|
| committer | Anser <rostgans@tutamail.com> | 2026-08-16 23:28:44 +0200 |
| commit | 5f068ebcc05703ac7e4f1051fbe5eaf21f0d7f75 (patch) | |
| tree | f2ca68a9d78ba693e2ac931659835dd83bbf605e /src | |
| parent | 06c44609bccebbeb3fa48050cbe2d91b0754b8a8 (diff) | |
added new ascii art. added a simple helper menu with flags -v -h
Diffstat (limited to 'src')
| -rw-r--r-- | src/ascii.c | 5 | ||||
| -rw-r--r-- | src/cfetch.c | 61 |
2 files changed, 63 insertions, 3 deletions
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 <stddef.h> #include <stdio.h> -#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 <unistd.h> #include <stddef.h> +#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"); +} |
