suntong/cascadia

make better use of stderr

mh-cbon opened this issue · 5 comments

Is it possible to better use stderr when I meet this output ?

I mean, see this

[mh-cbon@pc4 emd] $ curl --silent https://en.wikipedia.org/wiki/Changelog | cascadia -i -o -c 'div#mw-content-text > p:nth-child(2)' 1&>/dev/null

[mh-cbon@pc4 emd] $ curl --silent https://en.wikipedia.org/wiki/Changelog | cascadia -i -o -c 'div#mw-content-text > p:nth-child(2)' 2&>/dev/null

[mh-cbon@pc4 emd] $ curl --silent https://en.wikipedia.org/wiki/Changelog | cascadia -i -o -c 'div#mw-content-text > p:nth-child(2)'
1 elements for 'div#mw-content-text > p:nth-child(2)':
<p>A <b>changelog</b> is a log or record of all notable changes made to a project. The project is often a <a href="/wiki/Website" title="Website">website</a> or software project, and the changelog usually includes records of changes such as bug fixes, new features, etc. Some <a href="/wiki/Open_source" class="mw-redirect" title="Open source">open source</a> projects include a changelog as one of the top level files in their distribution.</p>

I thin this part 1 elements for 'div#mw-content-text > p:nth-child(2)': should be sent on stderr,
everything else to stdout.

what do you think ?

Or a -q|--quiet option ?

In fact, i prefer the -q option.

k.

Hmmm... Can you try the following?

 echo '<input type="radio" name="Sex" value="F" />' | tee /tmp/cascadia.xml | cascadia -i -o -c 'input[name=Sex][value=M]'
 cascadia -i /tmp/cascadia.xml -o -c 'input[name=Sex][value=F]' > /dev/null 
 cascadia -i /tmp/cascadia.xml -o -c 'input[name=Sex][value=F]' 2> /dev/null 

'cause I think you somehow get the redirection messed up:

$ cascadia -i /tmp/cascadia.xml -o -c 'input[name=Sex][value=F]' > /dev/null 
1 elements for 'input[name=Sex][value=F]':

$ cascadia -i /tmp/cascadia.xml -o -c 'input[name=Sex][value=F]' 2> /dev/null 
<input type="radio" name="Sex" value="F"/>

But I'll add the -q|--quiet option...

Now,

$ cascadia -i /tmp/cascadia.xml -o -c 'input[name=Sex][value=F]' -q
<input type="radio" name="Sex" value="F"/>

Closed in 87e4c58