Hacker News new | ask | show | jobs
by knuckle_cake 5883 days ago
Interesting, but it looks to require irb, heavily pollutes the global namespace with commands, and assumes I want to use --options-with-dashes. This is another 'close, but not quite' example.

The current implementation is that I have a hardware instance (like a CPU) that I want to monitor. To do that, I create a new monitor object, and tell it to monitor the hardware instance, and the monitor will mix itself in from there. It's not good if extra methods show up in the global namespace just for command parsing within a single module of the app. The monitor is just a part of this application, and a part that will not be used often by most users.

Everything I see feels like it's inches from what I really need. So close yet so far :)

1 comments

Another option that comes to mind is Thor by yehuda katz (took me ten minutes to recall the name!): http://yehudakatz.com/2008/05/12/by-thors-hammer/

otoh, there are some simple ones you could possible customize: i once studied and modified Choice (by Chris Wainstrath).

I'd really like to know if you find something that helps you, or what you did eventually.

I looked at both already. Both assume ARGV-like command strings with --long-switches with no way to get around that without significant rewriting/additional feature work.

Of everything, cmdparse is closest to what I want (by a significant margin,) but it's GPL (not LGPL :( ) so I'm not even sure I can use it in a non-GPL app. If cmdparse were under less-restrictive licensing I would have just hacked it up and released it already. I had already started doing so until I saw the license.

Right now, just writing a DSL is likely going to be my solution. I can bind an irb session to the monitor to keep scope from running away I think. Writing my own command parsing library just isn't interesting enough to me and I don't think I would ever finish it. This itch isn't quite that strong, at least not now.

What I really should do and am going to do later is look into irc clients written in ruby to see how they are doing it. They would probably run into this same problem.

Looking into said IRC clients, they all look to use regexps like I'm also doing. buh.