Hi all,
A few quick questions out there for people using HighLine. I’ve been
looking at the examples and the readline one looks similar to what I
want to do. Basically, I’d like the user to be able to type commands
and then have my program execute them. However, I’m trying to work with
the example but can’t figure out how to take it to the next step.
Here’s the example:
loop do
cmd = ask("Enter command: ", %w{save load reset quit}) do |q|
q.readline = true
end
say(“Executing “#{cmd}”…”)
break if cmd == “quit”
end
I’d like to be able to type a command such as load foobar or save foo
where the command takes a second parameter that isn’t explicitely known
beforehand. Is there anyway to do that? I tried passing in regular
expressions but couldn’t get anywhere.
Also, another question about highline. I have a list that’s several
rows and columns. I’d like the current list to update with new values
instead of printing a new list. I looked at the overwrite example but
it only seems to work with one line. Is this possible at all?
On Mar 30, 2007, at 2:10 AM, Raymond O’Connor wrote:
A few quick questions out there for people using HighLine. I’ve been
looking at the examples and the readline one looks similar to what I
want to do. Basically, I’d like the user to be able to type commands
and then have my program execute them.
Have a look at menus.rb in HighLine’s examples directory. The last
example in that file is almost exactly what you want to do.
Also, another question about highline. I have a list that’s several
rows and columns. I’d like the current list to update with new values
instead of printing a new list. I looked at the overwrite example but
it only seems to work with one line. Is this possible at all?
HighLine doesn’t currently support anything that would help you here,
no. It might be worth adding a cross-platform clear method, which
sounds like it would serve here…
Thanks for the help! I have a nice shell working now. I’ve run into
another snag though. Is there anyway to print out nicely formatted
tables? Ive tried just doing consecutive lists but even though they
have the same number of columns they don’t really line up all that well.
Thanks,
Ray