1
0

Readme has been updated.

This commit is contained in:
Alexander Andreev 2020-06-05 03:49:23 +04:00
parent f58b675107
commit da1ed3c436

View File

@ -11,8 +11,10 @@ banknots, but table will become indeed wide.
Many years ago I wrote a little script to store info on how much coins I have 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. in my piggy bank. It used SQLite 3 database for it and was hardcoded to rubles.
Why had I use whole SQL database? That was the first time I tried SQLite in
Python.
This year I came up with an idea that it would be good to learn on how to make Once 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 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 rewritten to support any currency. Database was thrown away and its place was
took by a simple text format. took by a simple text format.
@ -30,75 +32,79 @@ optionally, print a list of transactions.
## Common flags ## Common flags
```bash ```bash
piggybank-* [(-h | --help) | (-v | --version) | --list-currencies] piggybank-* [(-h | --help) | (-v | --version) | (-L | --list-currencies)
| --set-default-currency]
``` ```
`--help` to show help on what commands you can use. These flags are used with every sub-program.
`--help` to show help.
`--version` to show version of program. `--version` to show version of program.
`--list-currencies` to show what currencies supported and which one is default. `--list-currencies` to show what currencies supported and which one is default.
`--set-default-currency` to set a currency of your choice as default one.
## How to put coins in ## How to put coins in
```bash ```bash
piggybank-put <file> [-r | --reverse] <coins> [(-c | --currency) <currency>] piggybank-put [-r | --reverse] COINS in FILE of CURRENCY
``` ```
Here's how to put coins in a piggybank file. It will also create a file if it
doesn't exist.
`<file>` is a name of a piggy bank file wich may not have a .pb extension at the
end, it will be added automatically.
`<coins>` is a set of coins' counts separated with space character. For example:
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.
`--reverse` flag reverses the order of coins. By default they come from least `--reverse` flag reverses the order of coins. By default they come from least
significant face value to the most significant one and as stated above being 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, 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 e.g. 5 8 4 will be interpreted as 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 to be interpreted as 5 8 4 0 0 0. It is convenient if you want to add only
coins of low face value (e.g. cents or kopeks). coins of low face value (e.g. cents).
`--currency` parameter specifies the currency of a new piggy bank. It will not `COINS` is a set of coins' counts separated with space or comma character. For
change currency of an existing piggy bank. example: 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 6 0 5 12 if currency has 6 coins.
`FILE` is a name of a piggy bank file wich may not have a .pb extension at the
end, it will be added automatically.
`CURRENCY` specifies the currency of a new piggy bank. It will not change
currency of an existing piggy bank. ISO standard is used, e.g. EUR.
Case-insensitive.
### Examples: ### Examples:
```bash ```bash
piggybank-put example.pb 7 4 3 0 5 -c euro piggybank-put 7 4 3 0 5 in example.pb of EUR
piggybank-put example -r 0 4 6 piggybank-put -r 0 4 6 in example
``` ```
## How to take coins out ## How to take coins out
```bash ```bash
piggybank-take <file> [-r | --reverse] <coins> piggybank-take [-r | --reverse] COINS in FILE
``` ```
All the parameters are explained above. `--currency` flag is not applicable All the parameters are explained above.
here.
### Examples: ### Examples:
```bash ```bash
piggybank-take example.pb -r 0 0 4 piggybank-take -r 0 0 4 from example.pb
``` ```
## How to see what do you have ## How to see what do you have
```bash ```bash
piggybank-show <file> [-t | --transactions] piggybank-show FILE [ with (t | transactions)]
``` ```
Without `-t` flag only summarised information will be printed. `--transactions` It will print a summary table of what is stored in a piggy bank.
flag tells the program to print out all the transactions stored in a piggy bank.
`with t(ransactions)` will print also a table of all transactions stored in a
file.
### Examples: ### Examples:
```bash ```bash
piggybank-show example.pb -t piggybank-show example.pb with t
``` ```