Repl's and Cli's

1 view
Skip to first unread message

Ed Sumerfield

unread,
Sep 6, 2014, 2:10:09 PM9/6/14
to Cincinnati Ruby Brigade
I am building a little tool to offer command line interface to manage our vmware cloud. I want a cli and a repl and chose Pry as the repl so have code like this to define the Pry commands and what they do.

Pry.config.commands = Pry::CommandSet.new do
  command "configure", "Create a new configuration file" do
    CommandConfigure.new.run
  end
end

So now I want to make the same command to run from a cli argument. it looks like Thor is a great solution for a cli but this would mean duplicating all the command text and help information.

Ideally, I need some way to inject a command and arguments into pry that were entered on the command line instead of in the repl.

Pseudo code.

    Pry.submit(ARGV)

Anyone know how to do this?

Thanks.


Ed Sumerfield

unread,
Sep 6, 2014, 6:09:49 PM9/6/14
to Cincinnati Ruby Brigade
Found it.

    Pry.run_command(ARGV.join(" "))


Reply all
Reply to author
Forward
0 new messages