Browse Source

add line-delim and col-delim options

master
katherine 2 months ago
parent
commit
65cb88bf62
Signed by: katherine <ageha@airen-no-jikken.icu> GPG Key ID: 62E17859D559AEF3
3 changed files with 27 additions and 4 deletions
  1. +1
    -1
      reqs/simple-opt
  2. +23
    -3
      src/opt.c
  3. +3
    -0
      src/opt.h

+ 1
- 1
reqs/simple-opt

@@ -1 +1 @@
Subproject commit 197d36e32ddf85b49e82d5b84b9170f25f844ecb
Subproject commit 4fd21e3125c3003ecd0ae28c50c8656b62faefba

+ 23
- 3
src/opt.c View File

@@ -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", "<file>" },
"path to calendar file", "FILE" },
{ SIMPLE_OPT_STRING, 'e', "editor", true,
"text editor for editing calendars", "<cmd>" },
"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) {

+ 3
- 0
src/opt.h View File

@@ -12,6 +12,9 @@ void opt_parse(int argc, char **argv);
char* opt_calpath(void);
char* opt_editor(void);

char opt_line_delim(void);
char opt_col_delim(void);

enum opt_command_e opt_command(void);

#endif

Loading…
Cancel
Save