A lil' bud that helps you with stuff (it's a utility CLI).
Project description
๐ธ Blossy CLI ๐ธ
A multiuse utility CLI tool developed using:
- Python
- Typer (CLI building)
- Sly Lex Yacc (parsing)
๐ Features
- Calculate the value of an expression
- Calculate the value of an expression using time
- Count the quantity of characters in a text file
- Solve percentage equations
- Generate random numbers
- Stardardize the names of the files in a directory
๐ How to Install
To install the CLI, you'll only need to have Python installed on your machine. Then, run the following command:
$ python3 -m pip install blossy
โ๏ธ Behavior
๐งฎ Calculate
To calculate the value of an expression, use the calc
command. The following operators are supported:
- (expr)
- + expr
- - expr
- expr ^ expr
- expr * expr
- expr / expr
- expr + expr
- expr - expr
$ blossy calc "2*3+4^6"
4102
You can use the --visualize
flag to see the steps of the calculation, illustrated using postfix notation and a stack.
$ blossy calc "2*3+4^6" --visualize
$ 2 3 * 4 6 ^ +โ $
> Stack 2
$ 2 3 * 4 6 ^ +โ $
> Stack 3
$ 2 3 * 4 6 ^ +โ $
> 2 * 3 = 6
$ 6 4 6 ^ +โ $
> Stack 4
$ 6 4 6 ^ +โ $
> Stack 6
$ 6 4 6 ^ +โ $
> 4^6 = 4096
$ 6 4096 +โ $
> 6 + 4096 = 4102
$ 4102 $
> The result is 4102
โ Calculate Time
To calculate the value of an expression using time, use the calct
command. The following operators are supported:
- (expr)
- + expr
- - expr
- expr ^ expr
- expr * expr
- expr / expr
- expr + expr
- expr - expr
$ blossy calct "1:02:00 + 12:01*2"
1:26:02
You can use the --visualize
flag to see the steps of the calculation, illustrated using postfix notation and a stack.
$ blossy calct "1:02:00 + 12:01*2" --visualize
$ 1:02:00 12:01 2 * +โ $
> Stack 1:02:00
$ 1:02:00 12:01 2 * +โ $
> Stack 12:01
$ 1:02:00 12:01 2 * +โ $
> Stack 2
$ 1:02:00 12:01 2 * +โ $
> 12:01 * 2 = 0:24:02
$ 1:02:00 0:24:02 +โ $
> 1:02:00 + 0:24:02 = 1:26:02
$ 1:26:02 $
> The result is 1:26:02
๐ข Count
To count the quantity of characters in a text file, use the calc
command.
$ blossy count file.txt
Character count: 58
Blossy is my favorite puppy.
Did somebody say meatloaf?
You can use the --ignore-unnec
flag to ignore unnecessary whitespaces. That way, a sequence of whitespaces will be counted as only one character, and trailing whitespaces will be completely ignored.
$ blossy count file.txt --ignore-unnec
Character count: 55
Blossy is my favorite puppy. Did somebody say meatloaf?
You can also use the --ignore-ws
flag to ignore all whitespaces.
$ blossy count file.txt --ignore-ws
Character count: 47
Blossyismyfavoritepuppy.Didsomebodysaymeatloaf?
๐ Percentage
To solve percentage equations, use the perc
command. This command uses the formula ratio = part/whole
.
$ blossy perc --whole 100 --ratio 0.25
Part: 25.0
$ blossy perc --whole 100 --part 25
Ratio: 0.25
๐ฒ Random
To generate a random number between two given values (inclusive), use the rand
command.
$ blossy rand 1 10
2
You can specify the quantity of random numbers that'll be generated (the default is 1):
$ blossy rand 1 10 --quantity 5
2 7 1 5 1
๐๏ธ Standardize
To rename the files in a directory, using the format {prefix}-{id}
, use the stddz
command. Here's an example of how to use the command:
$ blossy stddz my-johnson nice-folder/
nice-folder/
โโโ my-johnson-000.png
โโโ my-johnson-001.png
โโโ my-johnson-002.png
โโโ my-johnson-003.png
You can use the flag --start
to specify the starting number for the IDs:
$ blossy stddz my-johnson nice-folder/ --start 10
nice-folder/
โโโ my-johnson-010.png
โโโ my-johnson-011.png
โโโ my-johnson-012.png
โโโ my-johnson-013.png
You can also use the flag --digits
to specify the quantity of digits that'll be used to represent the IDs (the default is 3):
$ blossy stddz my-johnson nice-folder/ --digits 2
nice-folder/
โโโ my-johnson-00.png
โโโ my-johnson-01.png
โโโ my-johnson-02.png
โโโ my-johnson-03.png
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file blossy-7.3.tar.gz
.
File metadata
- Download URL: blossy-7.3.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 062f24a0e4f50638952158b085ddcfcdd627f3e7fb7a6d63ce8976674dad0149 |
|
MD5 | 3a9dc693c973a90d273a559ade162162 |
|
BLAKE2b-256 | e0088aa97fdb08997211500f5648e01d62c709aef62174d1236f68a8506301de |
File details
Details for the file blossy-7.3-py3-none-any.whl
.
File metadata
- Download URL: blossy-7.3-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfec3ce62737b91817b1ffcad25f212ca0c2170ba87fb5dde3e0df2262e082df |
|
MD5 | f54fff1896a9af3ddaab44dae3164e17 |
|
BLAKE2b-256 | 54a4db1b5b056f3aeb7b401d0f79376731f8399d0a3b11d33d7d95b16152f6f2 |