jakob / TableTool

A simple CSV editor for the Mac
MIT License
1.32k stars 93 forks source link

Show and/or edit tabular data via the command line #79

Open doekman opened 5 years ago

doekman commented 5 years ago

Imagine the command tt or tabletool with which you can view (cat users.csv | tt) or edit (tt ~/Downloads/data.csv) tabular data from the command-line.

The functionality should be similar too mate from TextMate (for implementation, see mate on GitHub). For those unfamiliar with the command, see this document.

This would fix one big problem on the command-line.

fulldecent commented 5 years ago

This is outside of the project scope statement, which is published at https://github.com/jakob/TableTool#mission--project-scope--contributing

Sounds cool and I will be interested to look if you create this modern, limited Visicalc project.

weepy commented 4 years ago

I think he just means launching tt from the command line . That's what mate does.

doekman commented 4 years ago

That is correct. At the moment, I have this alias:

alias tt="open -b at.eggerapps.tabletool"

so I could open a file on the command line with tt filename.csv. However, there are some things that can't be done this way.

  1. the alias doesn't wait until the form has been closed
  2. can't directly use it with a pipe |
  3. set a window title (handy when using a pipe)
  4. select a line

Maybe with some advanced scripting this could be done with an external tool, but I think it might be useful for Table Tool.

For info, this is the help text from mate (mate --help):

mate 2.13.1 (Aug 26 2019)
Usage: mate [-wl<selection>t<filetype>m<name>rehv] [-u<identifier> | file ...]
       mate [-c<mark>] -s<mark>:<value> -l<line> [-u<identifier> | file ...]
       mate -c<mark> [-l<line>] [-u<identifier> | file ...]

Options:
 -w, --[no-]wait                 Wait for file to be closed by TextMate.
 -l, --line <selection>          Setup <selection> after loading file.
 -t, --type <filetype>           Treat file as having <filetype>.
 -m, --name <name>               The display name shown in TextMate.
 -r, --[no-]recent               Add file to Open Recent menu.
 -u, --uuid <identifier>         Reference already open document with
                                 <identifier>.
 -e, --[no-]escapes              Set this to preserve ANSI escapes from stdin.
 -s, --set-mark <mark>[:<value>] Set a mark with optional <value> (requires --line).
 -c, --clear-mark <mark>         Clear a mark (clears all marks without --line).
 -h, --help                      Show this information.
 -v, --version                   Print version information.

Files opened via mate are added to the recent menu unless
the file starts with a period, --wait or --no-recent is
specified, or the file is in the system’s temporary directory.

By default mate will wait for files to be closed if the command name
has a "_wait" suffix (e.g. via a symbolic link) or when used as a
filter like in this examples:

    ls *.tex|mate|sh    -w implied
    mate -|cat -n       -w implied (read from stdin)

The -l/--line option requires a selection in the following format:

    selection    = <range> ('&' <range>)*
    range        = <pos> | <normal_range> | <column_range>
    pos          = <line> (':' <column>)? ('+' <offset>)?
    normal_range = <pos> '-' <pos>
    column_range = <pos> 'x' <pos>
    line         = [1-9][0-9]*
    column       = [1-9][0-9]*
    offset       = [1-9][0-9]*