Coder Social home page Coder Social logo

Issue multiple commands in one call about tmsu HOT 7 CLOSED

oniony avatar oniony commented on May 25, 2024
Issue multiple commands in one call

from tmsu.

Comments (7)

oniony avatar oniony commented on May 25, 2024

Sounds reasonable, I'll have a think about how it can work.

FYI, I have made some changes in revisions be219acd and 0d4c6abd to improve untagging performance. (I will still look at your suggestion of reading actions from standard input.)

from tmsu.

oniony avatar oniony commented on May 25, 2024

This is now implemented. Pass - as the sole argument in order to read from standard input. Let me know of any issues.

df2c065

from tmsu.

0ion9 avatar 0ion9 commented on May 25, 2024

Good to see this progressing.

I have a bug report:
The parser breaks on arguments containing spaces.

for example the pretty conventional usage tag --tags="foo bar":

  • echo foo > /tmp/foo
  • create this input file, testcase1.txt:
-D /tmp/foo-bar.db tag --tags="foo bar" /tmp/foo
-D /tmp/foo-bar.db tags /tmp/foo
  • tmsu - < testcase1.txt

Result:
tmsu: New tag '"foo'.
tmsu: bar": no such file

If you make the obvious modification, removing the quotes, that is broken in a slightly different way:

tmsu: New tag 'foo'.
tmsu: bar: no such file
"foo

  • This problem also comes up with any filename that has a space in it. You can observe this by changing the database name to /tmp/foo bar.db in the above test-case.
  • I suggest that you either need a different convention (for example, one argument per line, with the end of a command being blank line or EOF), or need to allow spaces to be escaped. I'm personally in favor of the former, since it makes script generation very simple.

To rewrite the above test-script in the format I suggested, looks like this:

-D=/tmp/foo-bar.db
tag
--tags=foo bar
/tmp/foo

-D=/tmp/foo-bar.db
tags
/tmp/foo

A bit more stretched out, but pretty clear imo

I made a working prototype of this idea -- see read_args(), parse_file() , and I realized that a 'prelude' is also a good option. That's a section that comes before actual commands, specifying options to share between every executed command. To illustrate, that would look like

-D=/tmp/foo-bar.db

tag
--tags=foo bar
/tmp/foo

tags
/tmp/foo

for the same test-script, removing the need to repeat global options like -D or -v in each individual commandline.

from tmsu.

oniony avatar oniony commented on May 25, 2024

Thanks, I'll take a look. Not sure about the argument per line idea as I'd
rather keep a single syntax, plus you'd have to have an unintuitive blank
line between each subcommand.

I think the better solution is if I build a line parser that's aware of
quotation marks.

Sorry to get your hopes up when it so blatantly doesn't work.
On 18 Dec 2014 02:23, "0ion9" [email protected] wrote:

The parser breaks on spaces.
for example the pretty conventional usage tag --tags="foo bar":

  • echo foo > /tmp/foo
  • create this input file, testcase1.txt:

-D /tmp/foo-bar.db tag --tags="foo bar" /tmp/foo
-D /tmp/foo-bar.db tags /tmp/foo

  • tmsu - < testcase1.txt

Result:
tmsu: New tag '"foo'.
tmsu: bar": no such file

If you make the obvious modification, removing the quotes, that is broken
in a slightly different way:

tmsu: New tag 'foo'.
tmsu: bar: no such file
"foo

This problem also comes up with any filename that has a space in it.
You can observe this by changing the database name to /tmp/foo bar.db in
the above test-case.

I suggest that you either need a different convention (for example,
one argument per line, with the end of a command being blank line or EOF),
or need to allow spaces to be escaped. I'm personally in favor of the
former, since it makes script generation very simple.


Reply to this email directly or view it on GitHub
#6 (comment).

from tmsu.

oniony avatar oniony commented on May 25, 2024

Also, you can specify the database before the instruction to read from
standard input. In fact I believe you have to otherwise it will have
already opened the database by that point.
On 18 Dec 2014 02:30, "Paul Ruane" [email protected] wrote:

Thanks, I'll take a look. Not sure about the argument per line idea as I'd
rather keep a single syntax, plus you'd have to have an unintuitive blank
line between each subcommand.

I think the better solution is if I build a line parser that's aware of
quotation marks.

Sorry to get your hopes up when it so blatantly doesn't work.
On 18 Dec 2014 02:23, "0ion9" [email protected] wrote:

The parser breaks on spaces.
for example the pretty conventional usage tag --tags="foo bar":

  • echo foo > /tmp/foo
  • create this input file, testcase1.txt:

-D /tmp/foo-bar.db tag --tags="foo bar" /tmp/foo
-D /tmp/foo-bar.db tags /tmp/foo

  • tmsu - < testcase1.txt

Result:
tmsu: New tag '"foo'.
tmsu: bar": no such file

If you make the obvious modification, removing the quotes, that is broken
in a slightly different way:

tmsu: New tag 'foo'.
tmsu: bar: no such file
"foo

This problem also comes up with any filename that has a space in it.
You can observe this by changing the database name to /tmp/foo bar.db in
the above test-case.

I suggest that you either need a different convention (for example,
one argument per line, with the end of a command being blank line or EOF),
or need to allow spaces to be escaped. I'm personally in favor of the
former, since it makes script generation very simple.


Reply to this email directly or view it on GitHub
#6 (comment).

from tmsu.

oniony avatar oniony commented on May 25, 2024

Parsing now handles quoted text correctly.

763ed92

from tmsu.

BourgeoisBear avatar BourgeoisBear commented on May 25, 2024

Was this feature removed?

Building from latest, I get:

$ tmsu -
tmsu: invalid subcommand '-'

from tmsu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.