command-line help

28 views
Skip to first unread message

Ben Goodrich

unread,
Nov 29, 2013, 1:36:58 PM11/29/13
to stan...@googlegroups.com
Am I the only what that finds it annoying for the help on the command line to reprint the whole thing when I successfully match on a specific help piece? As in

goodrich@CYBERPOWERPC:/tmp/SU/KS$ ./normal sample adapt help
adapt
 
Warmup Adaptation
 
Valid subarguments: engaged, gamma, delta, kappa, t0
</Annoying>
Usage: ./
normal <arg1> <subarg1_1> ... <subarg1_m> ... <arg_n> <subarg_n_1> ... <subarg_n_m>

Begin by selecting amongst the following inference methods and diagnostics,
  sample      
Bayesian inference with Markov Chain Monte Carlo
  optimize    
Point estimation
  diagnose    
Model diagnostics

Or see help information with
  help        
Prints help
  help
-all    Prints entire argument tree

Additional configuration available by specifying
  id          
Unique process identifier
  data        
Input data options
  init        
Initialization method: "x" initializes randomly bewteen [-x, x], "0" initializes to 0, anything else identifies a file of values
  random      
Random number configuration
  output      
File output options

See ./normal <arg1> [ help | help-all ] for details on individual arguments.
<Annoying>

I was thinking of writing a Bash script that would walk through the specification of all the arguments interactively, so having it repeat the basic help every time makes more parsing work. In addition, would it be good if there was a little more description as to what each of the "Valid arguments" does? Anyone could go RTFM but usually for a command line option you are just looking for enough info to trigger your memory.

Ben

Marcus Brubaker

unread,
Nov 29, 2013, 3:23:18 PM11/29/13
to stan...@googlegroups.com
+1

At the very least, having the specific subcommand help come *after* the standard blurb would be better.  On smaller screens I often never see the specific subcommand help because it's scrolled off screen.

Cheers,
Marcius


--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ben Goodrich

unread,
Dec 1, 2013, 5:26:44 PM12/1/13
to stan...@googlegroups.com
On Friday, November 29, 2013 1:36:58 PM UTC-5, Ben Goodrich wrote:
I was thinking of writing a Bash script that would walk through the specification of all the arguments interactively

I went through with that, so see the attached script. Judging from the fact that it took me N takes to write it, it is probably pretty fragile in addition to being Bash-centric, possibly GNU-centric (it uses sed, awk, grep, and parallel), and unlikely to work as is on Windows even if you have the tools installed. But it does now work for me, as can be seen from the attached text file.

Somebody with a different setup tell me if it works for you. You can turn on tracing with the -x switch as in

bash -x stanhelper.sh STANMODEL CHAINS

Some more annoying things with the command-line: Stan v1.3.0 would append the chain id to the output file automatically but Stan v2.0.1 does not (so the example on page 29 of the manual is flawed because it writes to the same samples.csv file four times). Also Stan v1.3.0 allowed refresh to be zero or negative to suppress the output but Stan v2.0.1 does not.

Ben

stanhelper.sh
stanhelper.txt

Bob Carpenter

unread,
Dec 1, 2013, 10:16:17 PM12/1/13
to stan...@googlegroups.com


On 12/1/13, 5:26 PM, Ben Goodrich wrote:
> On Friday, November 29, 2013 1:36:58 PM UTC-5, Ben Goodrich wrote:
>
> I was thinking of writing a Bash script that would walk through the specification of all the arguments interactively
>
>
> I went through with that, so see the attached script. Judging from the fact that it took me N takes to write it, it is
> probably pretty fragile in addition to being Bash-centric, possibly GNU-centric (it uses sed, awk, grep, and parallel),
> and unlikely to work as is on Windows even if you have the tools installed. But it does now work for me, as can be seen
> from the attached text file.
>
> Somebody with a different setup tell me if it works for you. You can turn on tracing with the -x switch as in
>
> |
> bash -x stanhelper.sh STANMODEL CHAINS
> |

I'd rather not start distributing scripts with extensive
dependencies as part of Stan.

I think it'll be easier to maintain if we just fix the
command-line tool to do what we want. But I can understand
that it's not going to be a high priority and you may want
it now. And we may not be able to generate a consensus on
what the command-line tool should do.

Michael --- what do you think?

So maybe you (Ben) could put it in something like its own
repository along the lines of the gnu-plot-based diagnostics
Michael has created and the emacs mode.

(Sorry if this was your intent all along. I don't mind
stating the obvious, but it can be annoying for readers.)

> Some more annoying things with the command-line: Stan v1.3.0 would append the chain id to the output file automatically
> but Stan v2.0.1 does not (so the example on page 29 of the manual is flawed because it writes to the same samples.csv
> file four times).

I'll fix the manual. I added Ben's comment to the existing
issue for updating the manual:

https://github.com/stan-dev/stan/issues/325?source=cc

> Also Stan v1.3.0 allowed refresh to be zero or negative to suppress the output but Stan v2.0.1 does not.

Good idea. Let's see what Michael says. I created a new issue with
milestone "future" and nobody assigned:

https://github.com/stan-dev/stan/issues/427

- Bob

Ben Goodrich

unread,
Dec 1, 2013, 10:47:17 PM12/1/13
to stan...@googlegroups.com
On Sunday, December 1, 2013 10:16:17 PM UTC-5, Bob Carpenter wrote:
On 12/1/13, 5:26 PM, Ben Goodrich wrote:
> On Friday, November 29, 2013 1:36:58 PM UTC-5, Ben Goodrich wrote:
>
>     I was thinking of writing a Bash script that would walk through the specification of all the arguments interactively
>
>
> I went through with that, so see the attached script. Judging from the fact that it took me N takes to write it, it is
> probably pretty fragile in addition to being Bash-centric, possibly GNU-centric (it uses sed, awk, grep, and parallel),
> and unlikely to work as is on Windows even if you have the tools installed. But it does now work for me, as can be seen
> from the attached text file.
>
> Somebody with a different setup tell me if it works for you. You can turn on tracing with the -x switch as in
>
> |
> bash -x stanhelper.sh STANMODEL CHAINS
> |

I'd rather not start distributing scripts with extensive
dependencies as part of Stan.

I don't really care if it gets distributed since I mostly wrote it so that I could manage the command-line options. But can we stop pretending that we don't already depend on grep and sed?

goodrich@CYBERPOWERPC:/opt/stan$ git grep -n -w -e "awk" -e "grep" -e "sed" makefile make/ | cat
make
/manual:3:MAJOR_VERSION := $(shell grep MAJOR_VERSION src/stan/version.hpp | sed -e 's/.*\"\([^]]*\)\".*/\1/g')
make
/manual:4:MINOR_VERSION := $(shell grep MINOR_VERSION src/stan/version.hpp | sed -e 's/.*\"\([^]]*\)\".*/\1/g')
make
/manual:5:PATCH_VERSION := $(shell grep PATCH_VERSION src/stan/version.hpp | sed -e 's/.*\"\([^]]*\)\".*/\1/g')
make
/models:75: sed -e 's,\($(notdir $(basename $(MODEL_HEADER)))\)\.o[ :]*,$@ : ,g' < $@.$$$$ > $@; \
make
/tests:202: sed -e 's,\($(notdir $*)\)\(_test\)\.o[ :]*,$(dir $@)\1.o $@ : ,g' < $@.$$$$ > $@; \
makefile
:87:    sed -e 's,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g' < $@.$$$$ > $@; \
makefile
:97:    sed -e 's,\($(notdir $*)\)\.o[ :]*,$(dir $@)\1.o $@ : ,g' < $@.$$$$ > $@; \

So no awk, but I have never seen a computer that had grep and sed but not awk. And these tools change like once a decade. Still, I don't know if the stanhelper.sh script works with the bsd versions of these things.

Ben

Bob Carpenter

unread,
Dec 1, 2013, 11:42:50 PM12/1/13
to stan...@googlegroups.com
I wasn't pretending! I didn't realize (or just plain forgot) we had
that dependency in the makefiles. Ironically, grep would've told me.

Are grep and sed distributed with the Rtools toolchain? You can
certainly get them as part of Cygwin, though I don't know if
they're the BSD versions or not.

I assume they're in all the Linux distros.

They're also built into Mac OS.
The built-in sed and grep are the BSD versions:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sed.1.html

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/grep.1.html

For awk, the best I can sort out is:

~$ awk --version
awk version 20070501

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/awk.1.html

I'm not at all worried about the stability of grep, sed, and awk.

If they're in the Rtools toolchain and the BSD versions of sed and grep
work for whatever we need, I don't have any objection to using them.
I'm a very light user of grep and have no idea what those cryptic sed
commands are doing in our makefiles, but I don't need to understand everything
as long as it works.

We certainly haven't gotten any complaints from users about grep, sed, or awk
issues. So I'm assuming it's OK given that we're using grep and sed now.

- Bob
- Bob

Ben Goodrich

unread,
Dec 2, 2013, 12:12:38 AM12/2/13
to stan...@googlegroups.com
On Sunday, December 1, 2013 11:42:50 PM UTC-5, Bob Carpenter wrote:
I wasn't pretending!  I didn't realize (or just plain forgot) we had
that dependency in the makefiles.  Ironically, grep would've told me.

Are grep and sed distributed with the Rtools toolchain?

Yes (not sure about awk) and they are the GNU versions.

We certainly haven't gotten any complaints from users about grep, sed, or awk
issues.  So I'm assuming it's OK given that we're using grep and sed now.

I think things are (and have been, for a couple of years) fine with respect to grep and sed. I could probably make my script work without awk if necessary. But I can't imagine someone who wants to use Stan from the command-line not having standard command-line tools. I can imagine someone having bsd tools that don't work, so if someone could tell if / where it breaks with bsd tools, then I can probably fix it.

Ben

Reply all
Reply to author
Forward
0 new messages