aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: ce53eef23edb9132d12c2514bf2715d3acb5d990 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Malodivo
========

Budget planning in a fairy Kingdom of Malodivo.
For the whole story read the [plot](./doc/plot.md).


Requirements
============

Malodivo is written in Haskell with [GHC](http://www.haskell.org/ghc/).
All required Haskell libraries are listed in [malodivo.cabal](malodivo.cabal).
Use [cabal-install](http://www.haskell.org/haskellwiki/Cabal-Install) to fetch
and build all pre-requisites automatically.


Command-line utility
====================

The command-line utility `malodivo` provides a means to process input JSON
files and output JSON describing the actual amounts that go towards each bill
by each district.  This utility reads input JSON data from standard input
and writes output JSON data to standard output.

Usage
-----

```
Usage: malodivo [options] < input.json > output.json

Options:

  -h, --help               Show this message and exit

```


Examples
--------

Command:
```
$ malodivo < sample/simpleBudget.json
```

Input:
```json
{
  "bills": [
    {
      "name": "An Act to Construct the Great Wall of Malodivo",
      "ministry": "Defense",
      "amount": 300
    },
    {
      "name": "An Act to Construct Shelters for the Homeless",
      "ministry": "Welfare",
      "amount": 400
    }
  ],
  "districts": [
    {
      "name": "Palolene",
      "amount": 200
    },
    {
      "name": "SouthernPalolene",
      "amount": 400
    },
    {
      "name": "Lakos",
      "amount": 300
    }
  ]
}
```

Output (formatted with the [jq utility](https://stedolan.github.io/jq/)):
```json
[
  {
    "bill": {
      "amount": 300,
      "name": "An Act to Construct the Great Wall of Malodivo",
      "ministry": "Defense"
    },
    "districts": [
      {
        "amount": 100,
        "name": "Lakos"
      },
      {
        "amount": 66,
        "name": "Palolene"
      },
      {
        "amount": 133,
        "name": "SouthernPalolene"
      }
    ]
  },
  {
    "bill": {
      "amount": 400,
      "name": "An Act to Construct Shelters for the Homeless",
      "ministry": "Welfare"
    },
    "districts": [
      {
        "amount": 133,
        "name": "Lakos"
      },
      {
        "amount": 88,
        "name": "Palolene"
      },
      {
        "amount": 177,
        "name": "SouthernPalolene"
      }
    ]
  }
]

```