diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | docs/README.md | 1 | ||||
-rw-r--r-- | docs/tml.1.gz | bin | 914 -> 961 bytes | |||
-rw-r--r-- | draw.c | 21 |
4 files changed, 24 insertions, 2 deletions
@@ -6,6 +6,6 @@ !include !include/*.h !unix -!unix/* +!unix/*.c !windows -!windows/* +!windows/*.c diff --git a/docs/README.md b/docs/README.md index d48fd82..5e138ce 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,4 +54,5 @@ tml -c /path/to/config ``` For Documentation of the configuration file, see [tml-config](tml-config.md). +For a help message and list of flags, `tml --help`. If you installed tml, you can also consult **tml**(1) and **tml-config**(5). diff --git a/docs/tml.1.gz b/docs/tml.1.gz Binary files differindex f93cd14..388d9b8 100644 --- a/docs/tml.1.gz +++ b/docs/tml.1.gz @@ -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(); |