Skip to content

Commit

Permalink
ASV/USV essential code -- on-line help and docs up next
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Sep 2, 2019
1 parent d210a86 commit f8cf06d
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions c/cli/mlrcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
#define DEFAULT_COMMENT_STRING "#"
#define DEFAULT_MAX_FILE_SIZE_FOR_MMAP (4LL*1024LL*1024LL*1024LL)

// ASCII 1f and 1e
#define ASV_FS "\x1f"
#define ASV_RS "\x1e"

// Unicode code points U+241F and U+241E
#define USV_FS "\xe2\x90\x9f"
#define USV_RS "\xe2\x90\x9e"

// ----------------------------------------------------------------
static mapper_setup_t* mapper_lookup_table[] = {

Expand Down Expand Up @@ -1560,6 +1568,30 @@ int cli_handle_reader_options(char** argv, int argc, int *pargi, cli_reader_opts
preader_opts->ifs = "\t";
argi += 1;

} else if (streq(argv[argi], "--iasv")) {
preader_opts->ifile_fmt = "csv";
preader_opts->ifs = ASV_FS;
preader_opts->irs = ASV_RS;
argi += 1;

} else if (streq(argv[argi], "--iasvlite")) {
preader_opts->ifile_fmt = "csvlite";
preader_opts->ifs = ASV_FS;
preader_opts->irs = ASV_RS;
argi += 1;

} else if (streq(argv[argi], "--iusv")) {
preader_opts->ifile_fmt = "csv";
preader_opts->ifs = USV_FS;
preader_opts->irs = USV_RS;
argi += 1;

} else if (streq(argv[argi], "--iusvlite")) {
preader_opts->ifile_fmt = "csvlite";
preader_opts->ifs = USV_FS;
preader_opts->irs = USV_RS;
argi += 1;

} else if (streq(argv[argi], "--idkvp")) {
preader_opts->ifile_fmt = "dkvp";
argi += 1;
Expand Down Expand Up @@ -1713,6 +1745,30 @@ int cli_handle_writer_options(char** argv, int argc, int *pargi, cli_writer_opts
pwriter_opts->ofs = "\t";
argi += 1;

} else if (streq(argv[argi], "--oasv")) {
pwriter_opts->ofile_fmt = "csv";
pwriter_opts->ofs = ASV_FS;
pwriter_opts->ors = ASV_RS;
argi += 1;

} else if (streq(argv[argi], "--oasvlite")) {
pwriter_opts->ofile_fmt = "csvlite";
pwriter_opts->ofs = ASV_FS;
pwriter_opts->ors = ASV_RS;
argi += 1;

} else if (streq(argv[argi], "--ousv")) {
pwriter_opts->ofile_fmt = "csv";
pwriter_opts->ofs = USV_FS;
pwriter_opts->ors = USV_RS;
argi += 1;

} else if (streq(argv[argi], "--ousvlite")) {
pwriter_opts->ofile_fmt = "csvlite";
pwriter_opts->ofs = USV_FS;
pwriter_opts->ors = USV_RS;
argi += 1;

} else if (streq(argv[argi], "--omd")) {
pwriter_opts->ofile_fmt = "markdown";
argi += 1;
Expand Down Expand Up @@ -1842,6 +1898,38 @@ int cli_handle_reader_writer_options(char** argv, int argc, int *pargi,
pwriter_opts->ofs = "\t";
argi += 1;

} else if (streq(argv[argi], "--asv")) {
preader_opts->ifile_fmt = pwriter_opts->ofile_fmt = "csv";
preader_opts->ifs = ASV_FS;
pwriter_opts->ofs = ASV_FS;
preader_opts->irs = ASV_RS;
pwriter_opts->ors = ASV_RS;
argi += 1;

} else if (streq(argv[argi], "--asvlite")) {
preader_opts->ifile_fmt = pwriter_opts->ofile_fmt = "csvlite";
preader_opts->ifs = ASV_FS;
pwriter_opts->ofs = ASV_FS;
preader_opts->irs = ASV_RS;
pwriter_opts->ors = ASV_RS;
argi += 1;

} else if (streq(argv[argi], "--usv")) {
preader_opts->ifile_fmt = pwriter_opts->ofile_fmt = "csv";
preader_opts->ifs = USV_FS;
pwriter_opts->ofs = USV_FS;
preader_opts->irs = USV_RS;
pwriter_opts->ors = USV_RS;
argi += 1;

} else if (streq(argv[argi], "--usvlite")) {
preader_opts->ifile_fmt = pwriter_opts->ofile_fmt = "csvlite";
preader_opts->ifs = USV_FS;
pwriter_opts->ofs = USV_FS;
preader_opts->irs = USV_RS;
pwriter_opts->ors = USV_RS;
argi += 1;

} else if (streq(argv[argi], "--dkvp")) {
preader_opts->ifile_fmt = "dkvp";
pwriter_opts->ofile_fmt = "dkvp";
Expand Down

0 comments on commit f8cf06d

Please sign in to comment.