19 December 2011

Fish 4.18 Released: Aliases, Sequences, Duck Typing and More

It has been an unconsionably long time since I last pushed a version of Fish to Github. The reason for this is mostly that, while adding various features, I broke a few things and wanted to get them all fixed before inflicting them on people. I believe they are now fixed (but do disabuse me of this notion if you discover otherwise.)

There is much that is new, though almost all changes are backwards compatible. Everything is documented in the new green-themed documentation, available (as usual) in Fluidinfo itself at

http://fluiddb.fluidinfo.com/about/fish/fish/index.html

The main changes are as follows:

  • You can omit the -a or -i on the tag, untag, show, get and tags commands. If you do so, Fish will use the first argument instead, assuming that if it looks like a UUID, it is a UUID, and if not, that it isn’t. For these purposes, UUIDs must be expressed with lower-case hex digits and include the dashes in 88888888-4444-4444-4444-cccccccccccc formation. So now the following both work where before they would have generated errors:

    $ fish show Paris rating /about /id
    Object with about="Paris":
      /njr/rating = 10
      /fluiddb/about = "Paris"
      /id = "17ecdfbc-c148-41d3-b898-0b5396ebe6cc"
    
    $ fish show 17ecdfbc-c148-41d3-b898-0b5396ebe6cc rating /about /id
    Object 17ecdfbc-c148-41d3-b898-0b5396ebe6cc:
      /njr/rating = 10
      /fluiddb/about = "Paris"
      /id = "17ecdfbc-c148-41d3-b898-0b5396ebe6cc"

    Needless to say, the longer -a and -i forms work, and are useful if you want to tag multiple objects in one command (since they may be repeated).

  • The tags command now displays the tags in alphabetical order, except for the about tag, which is always listed first.

  • Fish now supports simple aliases, which effectively allow you to add commands to Fish. A simple example is:

    fish alias eiffel 'show -a "Eiffel Tower"'

    which allows commands like eiffel rating to be used in place of show -a "Eiffel Tower" rating.

    Aliases are stored in Fluidinfo, with private tags on objects whose about tag is the name of the alias. For example, with the alias definition above, the object with about tag paris has a tag njr/.fish/alias added to it with its value set to the expansion text for the alias:

    $ fish alias paris
    paris:
      njr/.fish/alias = "show -a "Paris""

    (Obviously, the quoting here is slightly unfortunate; I will fix that some time.)

    Aliases are also cached locally in the file-system; the cache is updated from Fluidinfo using the new sync command or whenever Fish is entered in interactive mode (by typing Fish).

    Because aliases are stored in Fluidinfo, they can be shared between multiple copies of Fish, and also with the online version Shell-Fish.

    The cache can be viewed with showcache.

  • Support for sequences has been added. Sequences provide a convenient way of storing a numbered collection of items that are added to over time. They are described in a previous blog post (Sequences in Fluidinfo).

    Briefly, in the simplest case, a sequence of remarks is defined by saying:

    $ fish mkseq remark

    This creates two new aliases:

    • remark is used to add a new remark, using the alias

      $ fish alias
      remark:
        njr/.fish/alias = "seq /njr/remark"
    • remarks is used to look at (or search) remarks, using the alias remarks:

      njr/.fish/alias = "listseq /njr/remark"

    Thus if we say:

    $ fish mkseq remark
    Next remark number: 0
    
    $ fish remark "Isn't this a remarkable first remark"
    0: Isn't this a remarkable first remark
    2011-12-18
    
    $ fish remark "...and this only slightly less remarkable"
    1: ...and this only slightly less remarkable
    2011-12-18

    then we will see:

    $ fish remarks
    0: Isn't this a remarkable first remark
    2011-12-18
    
    1: ...and this only slightly less remarkable
    2011-12-18

    By default, sequences are public, but you can easily make them private by specifying a tag in a private namespace (typically private); you can also specify the plural form. To set up the sequence as private, and use myremarks to list and search remarks, you would instead say:

    $ mkseq remark remarks private/remark

    For more details, see the previous blog post or the documentation.

  • Non-primitive types are now shown more sensibly (by show and tags). Previously, Fish would attempt to print even non-primitive types, with sometimes unfortunately consequences both in terms of the volume of output and its effects on terminals. For non-primitive types, output is now shown as below:

    $ fish show fish /fish/index.html
    Object with about="fish":
      /fish/index.html = <Non-primitive value of type text/html (size 8907)>
  • Display of set-valued tags is also improved, e.g.:

    $ fish tags 'artist:led zeppelin'
    Object with about="artist:led zeppelin":
      /fluiddb/about = "artist:led zeppelin"
      /musicbrainz.org/artist
      /musicbrainz.org/artist/end-date = "1980-09-25"
      /musicbrainz.org/artist/members = {
        "Jimmy Page"
        "John Bonham"
        "John Paul Jones"
        "Robert Plant"
      }
      /musicbrainz.org/artist/name = "Led Zeppelin"
      /musicbrainz.org/artist/sort-name = "Led Zeppelin"
      /musicbrainz.org/artist/start-date = "1968-01-01"
      /musicbrainz.org/artist/type = "group"
      /musicbrainz.org/mbid = "678d88b2-87b0-403b-b63d-5da7465aecc3"
  • The Fish API has been updated to take account of the renaming of FluidDB to Fluidinfo, and various tests have been changed to use more esoteric unicode characters.

  • Some operations are faster (because more use is made of the /values endpoint).

  • Finally, when Fish starts it checks the environment for the presence of the variable FISHUSER. If this is defined, the credentials in the startup file identified by the string specified in FISHUSER will be used, rather than the default ones. (This is mainly helpful if you want to use Fish with different Fluidinfo accounts in different shells concurrently.) Thus, if FISHUSER is set to foo (on UNIX), the credentials from ~/.fluidDBcredentials.foo will be used, rather than those in ~/.fluidDBcredentials.

So, obviously, there are quite a lot of changes, and though I’ve been using it for a while, some things might have broken. (I fixed some bugs yesterday; always dangerous!)

No comments:

Post a Comment

Labels