diff options
author | lshprung <lshprung@yahoo.com> | 2021-03-18 12:52:59 -0700 |
---|---|---|
committer | lshprung <lshprung@yahoo.com> | 2021-03-18 12:52:59 -0700 |
commit | d07470e8def83488365e4d7c6b03c10c5cb86563 (patch) | |
tree | 749d9ea04e9dc4fe7516b90143360f9d22bb7970 /draw.c | |
parent | b1e4742b8983aabdcd3fcd24d6623582c3b3d28c (diff) |
Added new launch flags
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -20,6 +20,7 @@ #define WIDTH (getmaxx(stdscr)) //width of the entire term #define HEIGHT (getmaxy(stdscr)) //height of the entire term +void print_help(char *exec_name); void update_display(bool resize); void draw_title(); void draw_win(WINDOW *new, char *title); @@ -51,6 +52,14 @@ int main(int argc, char **argv){ int prev_height; //used to check if the window was resized int i; + //If passed the quiet flag, disable output + if(argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))){ + print_help(argv[0]); + return 0; + } + + if(argc > 1 && (!strcmp(argv[1], "-q") || !strcmp(argv[1], "--quiet"))) freopen("/dev/null", "w", stdout); + //if a config path was given as an argument, set it accordingly if(argc > 2 && (!strcmp(argv[1], "-c") || !strcmp(argv[1], "--cfg_path"))) strcpy(cfg_path, argv[2]); else strcpy(cfg_path, find_config()); @@ -72,6 +81,9 @@ int main(int argc, char **argv){ //load cached data load_cache(&g_hover, &e_hover, &true_hover, cfg_path); + //reopen stdout for drawing menu + freopen("/dev/tty", "w", stdout); + initscr(); cbreak(); keypad(stdscr, true); @@ -159,6 +171,15 @@ int main(int argc, char **argv){ return 0; } +void print_help(char *exec_name){ + printf("Usage: %s [OPTION] [FILE]\n", exec_name); + printf("Draw an Ncurses Menu to Launch Media from\n\n"); + + printf(" -c, --config Specify a configuration file path\n"); + printf(" -h, --help Print this help message\n"); + printf(" -q, --quiet Suppress stdout messages\n"); +} + void update_display(bool resize){ if(WIDTH < 20 || HEIGHT < 6){ endwin(); |