Interactive config shell (config DSL)

Hi,

I want to build an interactive config shell. Maybe somebody knows such
cli config environments on routers or switches with auto completion and
help for the context.

On a switch it's maybe like:

interface gigaethernet 0/23

config-if> no shutdown
config-if> switchport
config-if> exit

As you see you can enter a context, what you don't see is, that you get
a context sensitive help whenever you type a questionmark and that you
have auto completion for every command on tab.

It's a DSL, of course.

So the basic problem is a good strategy for (automatic) mapping config
words to objects and methods. My first idea was to write an interface
command object and a common cli based on readline or rawline without
commands where I can plug-in as many commands as I want in as many
subcontextes as I want.

So I could reduce the problem to one context, which has a description
method, which knows his arguments types and possible values and has a
link to deeper contextes.

My only problem is that I've never worked with ruby introspection (if
you have a command object, you have to know it's name, methods and named
arguments, including types and maybe ranges of values).

I have to try it that way if you don't have a better idea or if you
don't know a library which supports generating such languages and a
comfortable mapping to objects and methods.

Any suggestions? Do you see a general problem with my approach?

Regards
Oli

···

--
Man darf ruhig intelligent sein, man muss sich nur zu helfen wissen

Any suggestions? Do you see a general problem with my approach?

Not sure I understand your approach. If you're looking to make a complex
shell, you may want to consider ripl, http://github.com/cldwalker/ripl\.
It can handle custom autocompletion via bond,
GitHub - cldwalker/bond: Mission: Easy custom autocompletion for arguments, methods and beyond. Accomplished for irb and any other readline-like console environments.

Gabriel

···

--
Posted via http://www.ruby-forum.com/\.