From 65cb88bf620581205fffba3049822f97961dbec1 Mon Sep 17 00:00:00 2001 From: katherine Date: Wed, 18 Dec 2019 08:43:22 -0700 Subject: add line-delim and col-delim options --- src/opt.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/opt.c') diff --git a/src/opt.c b/src/opt.c index 31b1186..6a958a6 100644 --- a/src/opt.c +++ b/src/opt.c @@ -14,9 +14,13 @@ static struct simple_opt options[] = { { SIMPLE_OPT_FLAG, 'v', "version", false, "print the version of every in use and exit" }, { SIMPLE_OPT_STRING, 'c', "calendar", true, - "path to calendar file", "" }, + "path to calendar file", "FILE" }, { SIMPLE_OPT_STRING, 'e', "editor", true, - "text editor for editing calendars", "" }, + "text editor for editing calendars", "CMD" }, + { SIMPLE_OPT_CHAR, '\0', "line-delim", true, + "line delimiter for scripting output" }, + { SIMPLE_OPT_CHAR, '\0', "col-delim", true, + "column delimiter for scripting output" }, { SIMPLE_OPT_END } }; @@ -36,7 +40,7 @@ void opt_parse(int argc, char **argv) if (options[0].was_seen) { simple_opt_print_usage(stdout, 80, argv[0], "[-c CALENDAR_FILE] [-e TEXT_EDITOR] [COMMAND]", - "every is a flexible, console-based event calendar", + "every is a simple console-based event calendar", options); printf( @@ -95,6 +99,22 @@ char* opt_editor(void) return getenv("EDITOR"); } +char opt_line_delim(void) +{ + if (options[4].was_seen) + return options[4].val.v_char; + + return '\n'; +} + +char opt_col_delim(void) +{ + if (options[5].was_seen) + return options[5].val.v_char; + + return '\t'; +} + enum opt_command_e opt_command(void) { if (result.argc > 0) { -- cgit v1.2.3