﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	launchpad_bug
2533	magic-folder CLI parsing error	warner	daira	"In a demo today, Zooko tried to join a magic-folder instance with the following (incorrect) command:

{{{
% tahoe magic-folder join ""URI:DIR2-RO:geydj2tsjteoxiezxwxmff46jq:nfczfkluafttupukia2umqthm2mqh3lu5olouby4nxcdcc36s3fa+URI:DIR2:yy5l52jcuj7k5khumae7stbtry:feo2jnoqcnhktoyggewibqjbr26unjajnudogaa2sbxhafnlvidq"" --basedir=c 
}}}

This is wrong for two reasons:

* the `--basedir` option needs to come between `magic-folder` and `join`, rather than at the end of the command
* it lacks the `LOCALDIR` positional argument, which is supposed to come after the `INVITATION-CODE` pair-of-dircaps

What happened was even worse:

* the command modified tahoe.cfg in the default basedir (`~/.tahoe/`), rather than the intended `./c`
* the command recorded `--basedir=c` as the name of the directory to sync. As in `./--basedir=c/files`.

I'm somewhat surprised that twisted.python.usage (the argument parser) was willing to accept a `--` -prefixed string as a positional argument.. it's a legal (if ill-advised) pathname, so it makes sense that it ""worked"", but leads to bad failure modes like this one. Some argument parsers (maybe argparse?) remove all `--`-prefixed strings first, attempt to parser them as options, then use only the remaining arguments to fill the positional slots. Such a parser would reject that command twice: once for having no --basedir option (at that level of the subcommands), and again for failing to have a positional argument at the expected location (since `--basedir=c` would have been removed by that point).

I'm not sure what tahoe can do about this, but it's tempting to make a rule that filenames must start with one of `[a-zA-Z0-9\.\/]`, or at least reject filenames that start with - or -- (and remind users to say `./-foo` if they really want that)."	defect	closed	normal	undecided	code-frontend-cli	1.10.1	fixed	usability error cli		
