From 33e775af4521a4861f3e50c6e11faf754a708824 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 11 Feb 2022 01:35:49 +0000 Subject: started hbar --- src/hbar/hbar.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/hbar/hbar.c diff --git a/src/hbar/hbar.c b/src/hbar/hbar.c new file mode 100644 index 0000000..5c90349 --- /dev/null +++ b/src/hbar/hbar.c @@ -0,0 +1,50 @@ +/* + * hbar + * + * create a horizontal progres bar across the screen + */ + +#include +#include +#include +#include + +int main (int argc, char **argv) { + struct winsize w; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + int width = w.ws_col; + + char *text; + int total; + int completed; + + int opt; + int option_index = 0; + + const char *optstring = "T:ucr:"; + static const struct option opts[] = { + {"text", required_argument, 0, 'T'}, + {"unit", optional_argument, 0, 'u'}, + {"color", optional_argument, 0, 'c'}, + {"reset", optional_argument, 0, 'r'} + }; + + while ((opt = getopt_long(argc, argv, optstring, opts, &option_index)) != -1) { + switch (opt) { + case 'T': + text = optarg; + } + } + + if (argc < optind + 2) { + fprintf(stderr, "Not enough arguments provided"); + } + + completed = atoi(argv[optind]); + total = atoi(argv[optind+1]); + + char output[width+6] = '\0'; + + return 0; +} + -- cgit v1.2.1