Skip to main content

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
  • 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

blossy-7.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

blossy-7.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file blossy-7.2.tar.gz.

File metadata

  • Download URL: blossy-7.2.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

Hashes for blossy-7.2.tar.gz
Algorithm Hash digest
SHA256 996125d66a9d9cf075850acc0d98a3d5cd9de0193a8d9396a3fa160a6d73a59c
MD5 26f95dd32801812e7a06e81b4832ebbf
BLAKE2b-256 e3d227ca31c359be826d4461dd41163407e3db5c7656729ce2ff238c768d0f2f

See more details on using hashes here.

File details

Details for the file blossy-7.2-py3-none-any.whl.

File metadata

  • Download URL: blossy-7.2-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

Hashes for blossy-7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b3c112265351372a2422274486910729c16654315526f5cbf2b37d8673947334
MD5 3102af8adc542863e4a521c86513906d
BLAKE2b-256 cbe5fe7f87ced430afbe8077127e079861b44e359d25815ab1412b4cec5700eb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page