Skip to content

roman-numerals - #1039

Open
kyellareddy wants to merge 4 commits into
raycast:masterfrom
kyellareddy:master
Open

kyellareddy wants to merge 4 commits into
raycast:masterfrom
kyellareddy:master

Conversation

@kyellareddy

Copy link
Copy Markdown
Contributor

Description

Script command that takes any Roman numeral and outputs the equivalent in Arabic numerals (1, 2, 3, etc.).

Type of change

  • New script command

Screenshot

Video of it working:
Note that it also says out loud "XIV is equal to 14" at the same time that it shows in the toast.

598513825-15e2cddb-0c07-45e3-8a5a-66d056ebb8d2.mov

Dependencies / Requirements

Checklist

@grzegorzkrukowski grzegorzkrukowski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

There are a few things to fix before this can be merged:

Repository conventions

  • File name: please use lowercase dash-case, e.g. roman-numerals.py (see File naming convention).
  • Metadata: please add @raycast.packageName Conversions (required in this repo) and a @raycast.description.
  • Location: this is a converter, so it belongs in commands/conversions/ next to scripts like hex-to-rgb.sh and what-day-is.py. The productivity folder is for tool-specific subfolders.

Behavior

  • Invalid Roman numerals are accepted. The parser only checks that each character is a valid symbol, not that the sequence is well-formed. For example, IIII → 4, IC → 99, VX → 5, IIX → 10, LL → 100, MMMM → 4000. One way to fix it is to convert the parsed number back with decimalToRoman and reject the input if the round trip does not reproduce the original string.
  • Numbers above 3999 currently produce a long string of Ms (try 99999) and then read every one of them aloud. Since the script already knows the limit is 3999, it should just reject larger input.
  • Speech is unconditional. Every run shells out to say and blocks until it finishes, including on error paths. That is unexpected for a converter. I would either drop it, or make it opt-in with a dropdown argument (e.g. @raycast.argument2 { "type": "dropdown", "placeholder": "Speak", "optional": true, "data": [...] }).

Minor

  • value() can be a dict lookup.
  • "That is not a valid English numeral" → "That is not a valid number".
  • romanToDecimal returns either an int or an error string. Returning None on failure (or raising) would make the caller simpler.

Happy to take another look once these are addressed!

Enhance Roman numeral conversion with speaking option and input validation.
@kyellareddy

Copy link
Copy Markdown
Contributor Author

Done, I added a new commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants