Skip to content

Commit

Permalink
Merge pull request #9 from coredump-ch/document-keys
Browse files Browse the repository at this point in the history
Spec: Document keys
  • Loading branch information
dbrgn authored Aug 19, 2024
2 parents 6ded9ea + 780ba63 commit 96fb2c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@ If a commit message starts with a special prefix, it will be parsed:
- `Transaction: <description>`: Create a transaction
- `Revert: <description>`: Revert a transaction

The `<description>` is a human-readable desription of the transaction.
The `<description>` is a human-readable description of the transaction.

The data of the transaction (in TOML format) is inserted between two markers
(`---` on a dedicated line). This allows adding more metadata before or after
the data section, which won't be parsed.

### TOML keys

The TOML section can use the following keys:

- `from` (required): The source account
- `to` (required): The destination account
- `amount` (required): The amount (must fit in i32, i.e. between `-2147483648`
and `2147483647` inclusive)
- `description` (optional): A free-form string to describe the transaction
- `meta` (optional): A table containing meta information

The following meta keys may be used, all of them are optional:

- `class`: The product class as a string, e.g. "softdrink".
- `ean`: The EAN code as an unsigned integer.

### Example commits

Deposit some cash:
Expand Down
4 changes: 2 additions & 2 deletions libgitcash/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ impl Transaction {

#[derive(Debug, Deserialize, Serialize)]
pub struct TransactionMeta {
pub class: String,
pub ean: u64,
pub class: Option<String>,
pub ean: Option<u64>,
}

#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Clone, Copy)]
Expand Down

0 comments on commit 96fb2c1

Please sign in to comment.