summaryrefslogtreecommitdiff
path: root/README.md
blob: 63db06dbe6caeb0f0fd02ea804cf24c28afa2c16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Coalpit

Coalpit is a library for building command-line program
interfaces. They are like command-line user interfaces, but for
programs.

Given a type, it derives instances to print and parse it as
command-line arguments.

The goal is to
faciliate
[the KISS principle](https://en.wikipedia.org/wiki/KISS_principle)
preservation for interfaces between system components in certain
(rather [unixy](https://en.wikipedia.org/wiki/Unix_philosophy))
architectures. Described in more detail in
the
[command-line program interface](https://defanor.uberspace.net/notes/command-line-program-interface.html) note.

Not production-ready yet, merely a prototype.


## Example

There is an example in `Example.hs`, but here are some bits:

```haskell
data Y = Foo Bool Int
       | Bar Int
       | Baz
data X = X String (Maybe Int) (Maybe [Int]) Y Y String
$(deriveArgs ''Y)
$(deriveArgs ''X)
```

`toArgs` serializes data into arguments, and `fromArgs` deserializes
it: `X "test" Nothing (Just [1,2,3]) (Foo True 1) Baz "end"` ↔ `x
"test" n j 1,2,3 foo t 1 baz "end"`.


## TODO

What it currently lacks, but what should be done, roughly in that
order:

* Proper parsing: use optparse-applicative, Parsec, or a custom
  parser, but something with error handling and more flexible.
* Named arguments (via records), not just positional ones.
* Optional arguments: once the named ones will be there, `Maybe a`
  could be handled nicer.
* Help messages.
* Documentation.