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

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for blossy-7.3.tar.gz
Algorithm Hash digest
SHA256 062f24a0e4f50638952158b085ddcfcdd627f3e7fb7a6d63ce8976674dad0149
MD5 3a9dc693c973a90d273a559ade162162
BLAKE2b-256 e0088aa97fdb08997211500f5648e01d62c709aef62174d1236f68a8506301de

See more details on using hashes here.

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

Hashes for blossy-7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dfec3ce62737b91817b1ffcad25f212ca0c2170ba87fb5dde3e0df2262e082df
MD5 f54fff1896a9af3ddaab44dae3164e17
BLAKE2b-256 54a4db1b5b056f3aeb7b401d0f79376731f8399d0a3b11d33d7d95b16152f6f2

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