[tahoe-dev] tahoe -d is awkward

Brian Warner warner at lothar.com
Wed May 11 13:50:00 PDT 2011


On 4/6/11 3:29 PM, Greg Troxel wrote:
> 
> So, I find myself doing
> 
> tahoe deep-check -d ~/.tahoe-gdt --add-lease --repair
> tahoe deep-check -d ~/.tahoe-pubgrid --add-lease --repair
> 
> and naturally would like to have aliases
> 
>   tahoep () { tahoe -d ${HOME}/.tahoe-pubgrid $*; }
>   tahoeg () { tahoe -d ${HOME}/.tahoe-gdt $*; }
> 
> but that won't work, because one must do "tahoe command [options]".
> Since -d is about everything, it would be nice if it were accepted at
> the beginning.
> 
> So:
> 
>   is this already an open ticket?
> 
>   if not, do people think my desire is sensible?

As zooko said, yes yes yes. "-d" is the sort of thing that should also
pay attention to an environment variable (like maybe $TAHOE_NODEDIR),
for exactly the same reasons (lots of other projects do that, like
$GIT_DIR).

The only reason I didn't put -d on the top-level options parser was
because there are several commands that don't use it. But at this point,
those commands are in the minority (just the 'tahoe debug' subcommands,
like 'tahoe debug dump-share' and 'tahoe debug trial'), and they can
just ignore the option.

For compatibility with folks' existing scripts, both the main command
and the subcommand should accept -d. The syntax should look like:

 tahoe [-d ONE] subcommand [-d TWO] args

and:

 def get_basedir():
   if TWO: return TWO
   if ONE: return ONE
   if sys.environ["TAHOE_NODEDIR"]: return sys.environ["TAHOE_NODEDIR"]
   return "~/.tahoe"


It looks like "tahoe -h" incorrectly suggests that you can use -d at the
top-level, so maybe I got halfway into this project and didn't finish it.

You'll want to look at src/allmydata/scripts/runner.py , at the
"Options" class, which is where ONE will go (probably in the form of a
'optParameters' attribute). The subcommand's TWO is handled by
scripts/common.py BaseOptions, from which most subcommand Options
parsers inherit (like scripts/cli.py VDriveOptions). You'll want to add
a method to BaseOptions called get_basedir(), which can implement the
TWO/ONE/$TAHOE_NODEDIR/.tahoe logic above.

Let me know how it goes, and if I can help at all.

cheers,
 -Brian


More information about the tahoe-dev mailing list