diff options
author | Andrés M <andmarti1424@users.noreply.github.com> | 2020-02-06 13:47:01 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 13:47:01 -0300 |
commit | 3b5a803cc3f8a0bfb2885b1582140e5cfbb9f5e5 (patch) | |
tree | fc4774f9dfcaecd08860292124665d4644875acc | |
parent | 3ce04c7bc690d732a25b976b3737c809e2146c39 (diff) | |
parent | 7f70295826df9fdf040d175bc78f77aca0f1c1c4 (diff) |
Merge pull request #386 from mipmip/pr-export-argument-mkd
add --export_mkd option
-rwxr-xr-x | src/doc | 3 | ||||
-rw-r--r-- | src/file.c | 14 | ||||
-rw-r--r-- | src/main.c | 5 |
3 files changed, 16 insertions, 6 deletions
@@ -1452,9 +1452,10 @@ Commands for handling cell content: You can set the --output parameter to save the results to a file. - Export to csv, tab or plain text formats without interaction: + Export to csv, tab, markdown or plain text formats without interaction: ./sc-im --quit_afterload --nocurses --export_csv ./sc-im --quit_afterload --nocurses --export_tab + ./sc-im --quit_afterload --nocurses --export_mkd ./sc-im --quit_afterload --nocurses --export_txt # (or just --export) If you set the --quit_afterload flag, SC-IM will quit after loading all @@ -1160,12 +1160,16 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) { int pid; wchar_t out[FBUFLEN] = L""; - sc_info("Writing file \"%s\"...", fname); - - if ((f = openfile(fname, &pid, NULL)) == (FILE *)0) { - sc_error ("Can't create file \"%s\"", fname); - return; + if (fname == NULL) + f = stdout; + else { + sc_info("Writing file \"%s\"...", fname); + if ((f = openfile(fname, &pid, NULL)) == (FILE *)0) { + sc_error ("Can't create file \"%s\"", fname); + return; + } } + struct ent * ent = go_end(); if (rn > ent->row) rn = ent->row; @@ -333,10 +333,15 @@ int main (int argc, char ** argv) { export_delim(NULL, '\t', 0, 0, maxrow, maxcol, 0); } + if (get_conf_value("export_mkd")) { + export_markdown(NULL, 0, 0, maxrow, maxcol); + } + if (get_conf_value("export") || get_conf_value("export_txt")) { export_plain(NULL, 0, 0, maxrow, maxcol); } + while ( ! shall_quit && ! atoi((char *) get_conf_value("quit_afterload"))) { // save current time for runtime timer gettimeofday(¤t_tv, NULL); |