2019-12-25 23:08:20 +04:00
|
|
|
Keep track of your piggy bank.
|
|
|
|
|
|
|
|
Every time you put coins in or take them out of your piggy bank, write here down
|
2019-12-29 22:40:50 +04:00
|
|
|
how much did you put or take. So you won't have to spend time counting them when
|
2019-12-25 23:08:20 +04:00
|
|
|
you decide to take them all out.
|
|
|
|
|
|
|
|
Yes, only coins, no banknots. Well, you actually can easily add support for
|
|
|
|
banknots, but table will become indeed wide.
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
# Backstory
|
|
|
|
|
|
|
|
Many years ago I wrote a little script to store info on how much coins I have
|
|
|
|
in my piggy bank. It used SQLite 3 database for it and was hardcoded to rubles.
|
|
|
|
|
|
|
|
This year I came up with an idea that it would be good to learn on how to make
|
|
|
|
packages for Python. And with no better ideas I took my piggy bank script to be
|
|
|
|
rewritten to support any currency. Database was thrown away and its place was
|
|
|
|
took by a simple text format.
|
|
|
|
|
2019-12-25 23:08:20 +04:00
|
|
|
# Usage
|
|
|
|
|
|
|
|
This is a CLI program that is broken down to three separate programs:
|
|
|
|
|
|
|
|
- `piggybank-put` — puts coins in a piggy bank and create a new one if
|
|
|
|
there is no such file;
|
|
|
|
- `piggybank-take` — takes coins from an existsing piggy bank file;
|
|
|
|
- `piggybank-show` — shows summarised information on a piggy bank and,
|
|
|
|
optionally, print a list of transactions.
|
|
|
|
|
|
|
|
## Common flags
|
|
|
|
|
|
|
|
```bash
|
|
|
|
piggybank-* [(-h | --help) | (-v | --version) | --list-currencies]
|
|
|
|
```
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
`--help` to show help on what commands you can use.
|
|
|
|
|
|
|
|
`--version` to show version of program.
|
|
|
|
|
|
|
|
`--list-currencies` to show what currencies supported and which one is default.
|
2019-12-25 23:08:20 +04:00
|
|
|
|
|
|
|
## How to put coins in
|
|
|
|
|
|
|
|
```bash
|
|
|
|
piggybank-put <file> [-r | --reverse] <coins> [(-c | --currency) <currency>]
|
|
|
|
```
|
|
|
|
|
|
|
|
Here's how to put coins in a piggybank file. It will also create a file if it
|
|
|
|
doesn't exist.
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
`<file>` is a name of a piggy bank file wich may not have a .pb extension at the
|
2019-12-25 23:08:20 +04:00
|
|
|
end, it will be added automatically.
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
`<coins>` is a set of coins' counts separated with space character. For example:
|
2019-12-25 23:08:20 +04:00
|
|
|
0 0 0 5 0 4 6 7. By default trailing zeroes will be added from the
|
|
|
|
left. So if you wrote something like 6 0 5 12 then it will be complemented to
|
|
|
|
0 0 0 0 6 0 5 12 if currency has 8 coins.
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
`--reverse` flag reverses the order of coins. By default they come from least
|
2019-12-25 23:08:20 +04:00
|
|
|
significant face value to the most significant one and as stated above being
|
|
|
|
complemented from left so a set shorter than number of coins in a currency,
|
|
|
|
e.g. 5 8 4 will be interpreted as 0 0 0 0 0 5 8 4. And this flag will make it
|
|
|
|
to be interpreted as 5 8 4 0 0 0 0 0. It is convenient if you want to add only
|
|
|
|
coins of low face value (e.g. cents or kopeks).
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
`--currency` parameter specifies the currency of a new piggy bank. It will not
|
2019-12-25 23:08:20 +04:00
|
|
|
change currency of an existing piggy bank.
|
|
|
|
|
|
|
|
### Examples:
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
```bash
|
|
|
|
piggybank-put example.pb 7 4 3 0 5 -c euro
|
|
|
|
piggybank-put example -r 0 4 6
|
|
|
|
```
|
2019-12-25 23:08:20 +04:00
|
|
|
|
|
|
|
## How to take coins out
|
|
|
|
|
|
|
|
```bash
|
|
|
|
piggybank-take <file> [-r | --reverse] <coins>
|
|
|
|
```
|
|
|
|
|
|
|
|
All the parameters are explained above. `--currency` flag is not applicable
|
2019-12-29 22:40:50 +04:00
|
|
|
here.
|
2019-12-25 23:08:20 +04:00
|
|
|
|
|
|
|
### Examples:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
piggybank-take example.pb -r 0 0 4
|
|
|
|
```
|
|
|
|
|
|
|
|
## How to see what do you have
|
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
```bash
|
|
|
|
piggybank-show <file> [-t | --transactions]
|
|
|
|
```
|
2019-12-25 23:08:20 +04:00
|
|
|
|
2019-12-29 22:40:50 +04:00
|
|
|
Without `-t` flag only summarised information will be printed. `--transactions`
|
|
|
|
flag tells the program to print out all the transactions stored in a piggy bank.
|
2019-12-25 23:08:20 +04:00
|
|
|
|
|
|
|
### Examples:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
piggybank-show example.pb -t
|
|
|
|
```
|