stillwwater / command_terminal

Unity Command Terminal: In-Game Console
MIT License
445 stars 60 forks source link

Add helper method to convert to any enum #16

Closed Sirrah closed 1 year ago

Sirrah commented 5 years ago

This adds a helper to convert a command argument to the given enum type. I've created a method, instead of a property, so that it can accept a generic type.

The behavior is similar to the existing helpers, i.e. parsing is case insensitive and return the default value for the given type in case of an error.

JimmyCushnie commented 5 years ago

Nice! This is also a feature of my fork Command Terminal Plus, maybe you'd be interested in that.

Sirrah commented 5 years ago

Looks good. Your implementation is a bit more explicit about types which is nice. Have you tried merging this or any other features back to this repo?

JimmyCushnie commented 5 years ago

You mean making pull requests? I did try that, but I'm new to git/github and fucked it up. Plus, seeing great and simple PRs like yours and this one go for so long without being acknowledged by @stillwwater is pretty discouraging.

If @stillwwater becomes active again I might make a bunch of PRs for him to review. But until then I'll just keep developing on my own fork. If you want to submit PRs to that, I promise to be timely about reviewing them 😉

stillwwater commented 5 years ago

This is a great addition, just change the formatting to be consistent with the rest of the code and I'll merge it. Also I'd prefer using TryParse instead of catching the exception, and using Terminal.Shell.IssueErrorMessage if parsing fails.

Thanks!

Edit: @JimmyCushnie I appreciate the concern, but with uni, work and other Unity projects it's difficult to handle everything, which is why I appreciate other people helping out! Though I don't want this project becoming too cluttered, Command Terminal was always meant to be simple enough that people can easily modify it to suit their own projects.