From 83414d8ff61f2e367dac4f571b7a03a035e83fa2 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Mon, 7 Oct 2024 22:10:47 +0200 Subject: Added help and version options --- main.c | 23 +++++++++++++++-------- version.h | 11 +++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 version.h diff --git a/main.c b/main.c index 4fc3d1a..c196cdd 100644 --- a/main.c +++ b/main.c @@ -3,11 +3,14 @@ #include #include +#include "version.h" + void help(const char *argv0) { printf("Usage: %s [options]\n" "\nAvailable options:\n" " -h,--help this help\n" " -v,--version show version\n" + " -l,--list list available devices\n" " -p,--port=client:port device port\n", argv0); } @@ -15,11 +18,11 @@ void help(const char *argv0) { int main(int argc, char *argv[]) { const char short_options[] = "hvlp"; const struct option long_options[] = { - {"help", 0, NULL, 'h'}, - {"version", 0, NULL, 'v'}, - {"list", 0, NULL, 'l'}, - {"port", 1, NULL, 'p'}, - {0}, + { "help", 0, NULL, 'h' }, + { "version", 0, NULL, 'v' }, + { "list", 0, NULL, 'l' }, + { "port", 1, NULL, 'p' }, + { 0 }, }; int c; @@ -29,13 +32,17 @@ int main(int argc, char *argv[]) { help(argv[0]); return 0; case 'v': - fprintf(stdout, "Version\n"); + fprintf(stdout, "ttdaw version %s\n", TTDAW_VERSION); + fprintf(stdout, "Website: %s.\n", TTDAW_WEBSITE); + fprintf(stdout, "%s\n", TTDAW_LICENSE); + fprintf(stdout, "%s\n", TTDAW_WARRANTY); + fprintf(stdout, "\n%s\n", TTDAW_AUTHOR); return 0; case 'l': - fprintf(stdout, "List\n"); + fprintf(stderr, "List feature is NOT implemented yet.\n"); return 0; case 'p': - fprintf(stdout, "Port\n"); + fprintf(stderr, "Port feature is NOT implemented yet.\n"); return 0; default: fprintf(stdout, "No option provided\n"); diff --git a/version.h b/version.h new file mode 100644 index 0000000..e5962f6 --- /dev/null +++ b/version.h @@ -0,0 +1,11 @@ +#ifndef TTDAW_VERSION_H +#define TTDAW_VERSION_H + +#define TTDAW_VERSION "0.1" +#define TTDAW_WEBSITE "https://github.com/mitjafelicijan/ttdaw" +#define TTDAW_LICENSE "This is free software: you are free to change and redistribute it." +#define TTDAW_WARRANTY "There is NO WARRANTY, to the extent permitted by law." +#define TTDAW_AUTHOR "Written by Mitja Felicijan ." + +#endif + -- cgit v1.2.3