aboutsummaryrefslogtreecommitdiff
path: root/src/cfetch.c
diff options
context:
space:
mode:
authorAnser <rostgans@tutamail.com>2026-08-16 23:18:06 +0200
committerAnser <rostgans@tutamail.com>2026-08-16 23:28:44 +0200
commit5f068ebcc05703ac7e4f1051fbe5eaf21f0d7f75 (patch)
treef2ca68a9d78ba693e2ac931659835dd83bbf605e /src/cfetch.c
parent06c44609bccebbeb3fa48050cbe2d91b0754b8a8 (diff)
added new ascii art. added a simple helper menu with flags -v -h
Diffstat (limited to 'src/cfetch.c')
-rw-r--r--src/cfetch.c61
1 files changed, 59 insertions, 2 deletions
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");
+}