I would like to have an input-field on my webpage, which allows users to interact with models and perform specific searches within specified models. The system should support various actions, primarily add (+), delete (!) and search (?).
- To add a new Todoitem to a todolist, the syntax would be like this: +todoitem Some text here #todolistname
- To delete a post, the syntax would be like this: !post nameofpost
- To search for a post, the syntax would be: ?post nameofpost
The previous examples adds and removes items from the current signed in user. I would also like the command line to support groups (identified by .groupname)
- A valid syntax to add a todoitem to todolist with name important ingroup school would be: +todoitem Some todo text #important.school
- Searching for all posts in a group would be: ?post .group
- Spaces and order should not matter, except for actual content to be added to model (like the todo text of a todo item). That means +todoitem.school#important Some todo text should give the same result as the input in #1.
Could anyone help me with a way of implementing this effectively in rails? That is how you could effectively search the input-string, decide what the user is trying to do (based on the prefix identificators), and then parsing the input into actual queries ?
Edit: To clarify the last paragraph, as I might have misused the word 'parsing', I was thinking of going through the input-string letter by letter, and then branching/dividing the information so that it can be easily used by pre-defined functions (which perform the queries).