tags 336343 + patch thanks * Alexander Tait Brotman <[EMAIL PROTECTED]> [2005-10-29 11:31]: > When attempting to use jack, the command line option parsing seems to be > broken, and perhaps inconsistent. > > jack -Q --encoder-name "lame" -t 3 --rename-fmt "%a-%l-%n-%t" > --unusable-chars " " --replacement-chars "_" > > In the first example, the program will replace the " " with "%" when > renaming. You can get it to work by using --replacement-chars="_", but > the man page doesn't say to do this.
Actually, jack is correct and this is a user error. However, jack can do better. The man page gives an example of a proper command line - even tough I see that the example is not rendered properly because of a syntax error (I'll fix this). Anyway, the correct example is: jack -Q --rename-fmt "%n-%t" --unusable-chars A I \; --replacement-chars a i \; In other words, you have to stop lists with a ';' sign, and since shells will interpret ';' to separate commands, you have to escape it. In your example the ; is missing, so the --replacement-chars "_" is simply seen as an argument to --unusable-chars... > --unusable-chars " " --replacement-chars "_" --save > In the second, the program will not save my preferences. If > I put the --save earlier in the command, then it does work. That's because --save is interpreted as another argument of the list given to --unusable-chars. Anyway, I agree this list stuff is not intuitive and that jack can do better. In particular, jack could recognize when a valid option is given as part of a list and then simply stop and take that option as the next one. This effectively means that the ; is no longer necessary to signal the end of a list, although it's still supported. Arne, what do you think? I think this has no negative side-effects at all and will really improve usability. --- jack_argv.py~ 2005-11-01 19:30:34.000000000 +0000 +++ jack_argv.py 2005-11-01 19:41:11.000000000 +0000 @@ -117,11 +117,23 @@ if ty == types.ListType: l = [] if origin == "argv": + valid_short_opts = [cf[key]['short'] for key in cf.keys() if cf[key].has_key('short')] + valid_long_opts = [cf[key]['long'] for key in cf.keys() if cf[key].has_key('long')] while 1: i, data = get_next(argv, i, alt_arg, 0) if data != None: if data == ";": break + # The end of a list has to be signaled with a semicolon but + # many users forget this; therefore, check whether the next list + # entry is a valid option, and if so, assume the end of the list + # has been reached. + if data.startswith("--") and data[2:].split('=', 1)[0] in valid_long_opts: + i -= 1 + break + if data.startswith("-") and len(data) == 2 and data[1] in valid_short_opts: + i -= 1 + break l.append(data) if alt_arg: # only one option in --opt=val form break -- Martin Michlmayr http://www.cyrius.com/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]