31 August 2009

Flags in FDB from version 1.18 onwards

I posted recently that FDB 1.18 has been released and that one of the changes in there was that my custom flags library for handling command line options (switches; flags; things like -a) has been replaced with the standard optparse library. (Thanks again, Yevgev (@xa4a_)

When I wrote that post, I hadn’t fully appreciated that this had subtly changed the behaviour of command line arguments, and in doing so invalidated some of the examples I posted.

Most people will almost certainly prefer the new behaviour (or at least, will probadbly find it more familiar), but since its different and inconsistent with previous published examples, I thought I’d better document it.

The main changes are as follows:

  • Single-letter options may no longer be conflated, i.e.

    USE   fdb tag -v -a DADGAD rating=10
    NOT   fdb tag -av DADGAD rating=10

    to specify that you want to set a rating of 10 on the object whose object whose about tag is DADGAD

  • -q, -a and -i now take the argument immediately following as the query, about-tag or ID, rather than using the first argument not tied to an option. So

    USE   fdb tag -v -a DADGAD rating=10
          fdb tag -sand -i edfaaf70-b9b5-42f1-ad4c-30601b70a2ac rating=10
          fdb tag -v -sand -q "has njr/rating" rating=10
    
    USE   fdb tag -a -v DADGAD rating=10
          fdb tag -i -sand edfaaf70-b9b5-42f1-ad4c-30601b70a2ac rating=10
          fdb tag -v -q -sand "has njr/rating" rating=10
  • options may now appear anywhere in the command

    USE  fdb tag -i -sand edfaaf70-b9b5-42f1-ad4c-30601b70a2ac rating=10
    OR   fdb tag -i edfaaf70-b9b5-42f1-ad4c-30601b70a2ac rating=10 -sand
    OR   fdb -i edfaaf70-b9b5-42f1-ad4c-30601b70a2ac tag rating=10 -sand
  • there are now long versions with -- available to go with the short (single-letter) form for each action. (Personally, I hate --, but I lost that battle years ago.) Specifically, you can use

    --about ABOUT, -a ABOUT  to specify an about tag of ABOUT
    --id ID, -i ID           to specify an id of ID
    --query QUERY, -q QUERY  to specify a query of QUERY
    --timeout N, -T N        to specify an Http timeout of N
    --sandbox, -s            to specify use of the sandbox
    --verbose, -v            to increase verbosity
    --debug, -D              for debug mode

No comments:

Post a Comment

Labels