Question

I ask a user for a string of cypher and use readline tab autocomplete to provide options, but would like to use several different option lists depending on which bit of the cypher statement it is.

A simplified cypher string looks like this:

(node_name:LABEL1:LABEL2 {key1: value1, key2: value2})

What I would like is to have one completion list for labels, and a dictionary of lists of values for each of the different property keys eg:

{key1: [option1, option2, option3], key2: [foo, bar, baz]}

Is there a way to have newline (or other similar library) know where it is in a cypher string so that it only displays options from the label list when it is in the label position and only options from the appropriate key list when the user is writing the properties.

Edit: This page gives an example of using a regular grammar with readline. It seems to answer my question so I'm marking this answered.

Was it helpful?

Solution 2

This page explains using a regular grammar with readline.

OTHER TIPS

Have a look at the rlcompleter module in teh python standard library. I used this technique myself recently. See (example): https://bitbucket.org/prologic/mio-lang/src/tip/mio/state.py#cl-30

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top