summaryrefslogtreecommitdiff
path: root/README.md
blob: 1d226a2f8cd5014dc107c7ba6ed00328e28bedc6 (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
# perc

A simple vibe-coded command-line percentage calculator written in Go.

## Installation

```bash
go install codeberg.org/snonux/perc/cmd/perc@latest
```

Or using mage:

```bash
mage install
```

## Usage

`perc` supports various percentage calculation formats:

### Calculate X% of Y

```bash
perc 20% of 150
# Output:
# 20.00% of 150.00 = 30.00
#   Steps: (20.00 / 100) * 150.00 = 0.20 * 150.00 = 30.00

perc what is 20% of 150
# Output:
# 20.00% of 150.00 = 30.00
#   Steps: (20.00 / 100) * 150.00 = 0.20 * 150.00 = 30.00
```

### Find what percentage X is of Y

```bash
perc 30 is what % of 150
# Output:
# 30.00 is 20.00% of 150.00
#   Steps: (30.00 / 150.00) * 100 = 0.20 * 100 = 20.00%
```

### Find the whole when X is Y% of it

```bash
perc 30 is 20% of what
# Output:
# 30.00 is 20.00% of 150.00
#   Steps: (30.00 / 20.00) * 100 = 1.50 * 100 = 150.00
```

## Building

Using mage:

```bash
mage build
```

Or using go directly:

```bash
go build -o perc ./cmd/perc
```

## Testing

```bash
mage test
```

## License

See LICENSE file for details.