Dsl/library for text interaction?

I've been doing a fair amount of work with Asterisk lately. It's got a
command-line interface that looks quite a bit like SMTP (and like lots of
other text-based send-a-line-and-get-a-response protocols).

Seems like there should be a generic library to build interfaces for these
sorts of things - is there? Some sort of DSL that helps you say things
like:

- the first thing on the line is the command "FOOBAR"
- it takes two required arguments, and one optional
- encode the required arguments using (base64/http/whatever)
- the response is one line starting with an integer result code
- when you get a response matching code X, execute a given block
- etc

- James Moore

you mean ruby?

:wink:

-a

···

On Sun, 17 Dec 2006, James Moore wrote:

I've been doing a fair amount of work with Asterisk lately. It's got a
command-line interface that looks quite a bit like SMTP (and like lots of
other text-based send-a-line-and-get-a-response protocols).

Seems like there should be a generic library to build interfaces for these
sorts of things - is there? Some sort of DSL that helps you say things
like:

- the first thing on the line is the command "FOOBAR"
- it takes two required arguments, and one optional
- encode the required arguments using (base64/http/whatever)
- the response is one line starting with an integer result code
- when you get a response matching code X, execute a given block
- etc

- James Moore

--
if you find yourself slandering anybody, first imagine that your mouth is
filled with excrement. it will break you of the habit quickly enough. - the
dalai lama

Perhaps you could use a parser generator?

http://rubyforge.org/projects/dhaka/

James Edward Gray II

···

On Dec 17, 2006, at 12:36 AM, James Moore wrote:

I've been doing a fair amount of work with Asterisk lately. It's got a
command-line interface that looks quite a bit like SMTP (and like lots of
other text-based send-a-line-and-get-a-response protocols).

Seems like there should be a generic library to build interfaces for these
sorts of things - is there? Some sort of DSL that helps you say things
like:

- the first thing on the line is the command "FOOBAR"
- it takes two required arguments, and one optional
- encode the required arguments using (base64/http/whatever)
- the response is one line starting with an integer result code
- when you get a response matching code X, execute a given block
- etc

If the data is regular enough, RedNails might do the trick
http://rednails.rubyforge.org/

···

On 12/17/06, James Moore <banshee@banshee.com> wrote:

- the first thing on the line is the command "FOOBAR"
- it takes two required arguments, and one optional
- encode the required arguments using (base64/http/whatever)
- the response is one line starting with an integer result code
- when you get a response matching code X, execute a given block
- etc