jwiegley/git-all — pull request #1 by AndrewRadev (2013-01-02 21:40:55+00:00)
Title: Move out default argument to cmdArgs invocation

Calling `git-all` in both of these ways is equivalent:

```
git-all
git-all status
```

However, adding a flag in the case when neither "status" nor "fetch" have been given as commands causes a crash:

```
git-all: Prelude.tail: empty list
git-all: thread blocked indefinitely in an MVar operation
```

`L.tail` is being called on `(arguments opts)`, which turns out to be an empty list. The reason is that, since no arguments have been given on the command-line, `arguments` is empty. This attempts to set the arguments to a default value:

``` haskell
opts <- withArgs (if L.null mainArgs then ["status"] else mainArgs)
(cmdArgs gitAll)
```

But it doesn't work if `mainArgs` is not null, and it can be not null if a flag was given, like `-v` or `-D`. A better solution is to use `opt "status"` to give a default value to `arguments`.

Unfortunately, `opts` from `cmdArgs` is somewhat oddly defined. It attempts to coerce its argument to a `String`, so when it's given a `Text`, it runs `show` on it, resulting in `"\"status\""`. This is why I use `T.unpack` to turn the `Text` string into a regular `[Char]`.