blob: 7ce4fdb455d37649a5dc0bb78d942ba327634332 (
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
|
# perc
A simple 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
perc what is 20% of 150
# Output: 20.00% of 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
```
### 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
```
## 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.
|