summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md40
1 files changed, 38 insertions, 2 deletions
diff --git a/README.md b/README.md
index bcefff4..cb38e87 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@ while keeping them language-agnostic and more user- and shell
scripting-friendly than JSON and similar formats.
Given a type, it derives instances to print and parse it as
-command-line arguments. The resulting deserialization wouldn't be as
-nice as that of
+command-line arguments, as well as to compose usage instructions. The
+resulting deserialization wouldn't be as nice as that of
e.g.
[optparse-generic](https://hackage.haskell.org/package/optparse-generic),
but the aim here is to handle more or less arbitrary types.
@@ -46,6 +46,12 @@ What would look like this in a shell:
--foobar foo 1 'a string' bar
```
+And its usage string -- like this:
+
+```
+[--something STRING] [--foobar (foo INT STRING | bar)] (foo INT STRING | bar)
+```
+
More verbose versions can be produced and parsed with
`alwaysUseSelName = True` and/or `omitNamedOptions = False`:
@@ -54,3 +60,33 @@ More verbose versions can be produced and parsed with
nothing just foo 1 'a string' bar
--something nothing --foobar just foo --arg1 1 --arg2 'a string' --foobar2 bar
```
+
+And here is output of the `help` function from the same file, with all
+the (alwaysUseSelName, omitNamedOptions) combinations:
+
+```
+(True,True)
+["--foo","[]","--bar","a string"]
+--foo ([] | : INT ([] | :...)) [--bar STRING]
+(True,True)
+["--foo","[]"]
+--foo ([] | : INT ([] | :...)) [--bar STRING]
+(True,False)
+["--foo","[]","--bar","just","a string"]
+--foo ([] | : INT ([] | :...)) --bar (nothing | just STRING)
+(True,False)
+["--foo","[]","--bar","nothing"]
+--foo ([] | : INT ([] | :...)) --bar (nothing | just STRING)
+(False,True)
+["[]","--bar","a string"]
+([] | : INT ([] | :...)) [--bar STRING]
+(False,True)
+["[]"]
+([] | : INT ([] | :...)) [--bar STRING]
+(False,False)
+["[]","just","a string"]
+([] | : INT ([] | :...)) (nothing | just STRING)
+(False,False)
+["[]","nothing"]
+([] | : INT ([] | :...)) (nothing | just STRING)
+```