phronmophobic / membrane.term

A terminal emulator in pure clojure
Eclipse Public License 1.0
53 stars 1 forks source link

Provide a better error message when :color-scheme can not be loaded #5

Closed phronmophobic closed 2 years ago

phronmophobic commented 2 years ago

If a color scheme cannot be loaded, the error message is very indirect. It should be more helpful.

Examples:

bash-3.2$ clojure -X com.phronemophobic.membrane.term/run-script :path '"script3.sh"' :width 90 :height 40 :color-scheme :foobar
Execution error (IllegalArgumentException) at com.phronemophobic.membrane.term.color-scheme/load-scheme (color_scheme.clj:65).
Cannot open <:foobar> as an InputStream.
bash-3.2$ clojure -X com.phronemophobic.membrane.term/run-script :path '"script.sh"' :color-scheme '"foobar"'
Namespace could not be loaded: com.phronemophobic.membrane.term
lread commented 2 years ago

Actually, I might scope this up a bit to validate all command line args. Would that work for you?

But it begs the question, should we maybe provide a better command-line experience via a -M main usage and just use something like docopt?

phronmophobic commented 2 years ago

To be honest, I almost never use clojure from the command line since I always have a repl available. I usually only add cli support so that I can put something in the readme. I'm happy to go with whatever you recommend for the cli interface.

lread commented 2 years ago

Hmmm, very interesting point.

I must ask then, is an improved error message/exception for color-scheme ideally for:

  1. command line user
  2. API user (maybe not? feels like a spec)
  3. both
phronmophobic commented 2 years ago

While the error messages currently aren't great, I think they're "acceptable". The unrelated Namespace message should be fixed in the next update to the clojure cli!

I was just going leave this until someone complained about it or until my OCD about unresolved issues compelled me to fix it.

I must ask then, is an improved error message/exception for color-scheme ideally for

Since you're one of the main consumers, I think you get to decide. If I had to pick one, I might prefer catering to the command line user since I'm not aware of any specific use cases other than people checking out the library and reading the Readme.

lread commented 2 years ago

Coolio, thanks @phronmophobic, the command-line usability is bothering me enough to try out a PR, my plan:

phronmophobic commented 2 years ago

This is really good stuff. Thanks again!