Command DNA

is the blueprint of the command which the yelo engine uses to parse the incoming command line. Based on the mentioned required args and optional args, a request JSON is prepared to be sent to your server.

We will go through an example to explain this.

A DNA is sort of a contract between yelo and you - the command developer. A command consists of various pathways. A single pathway can consist multiple required arguments, optional arguments and points to a single endpoint which will handle the request for this pathway.


Let's say you are trying to construct a command /pqr for you company named PQR technologies.

First there is the default pathway. This is the pathway expecting no arguments i.e. /pqr. This is sometimes the only pathway for many commands which are very simplistic and just do 1 thing always, for e.g.: /happy doesn't have or need arguments. It just fetches a happy gif and shows it. For more complex commands, the default pathway can serve as an introduction to your command/company or a help menu of various other pathways.

Example DNA

Let's say you want to create a /time_in command which takes in a country name and outputs the current time there.

    "name": "time_in",
    "url": "",
    "pathways": [
            "name": "in_country",
            "url": "",
            "reqargs": [
                    "name": "country",
                    "type": "/str"
            "optargs": []

/time_in United States of America
==> 3:13 PM

There is 1 pathway in this case (apart from the default pathway) named: 'in_country' Every pathway has a

  1. name
  2. url endpoint
  3. reqargs (list of required arguments)
  4. optargs (list of optional arguments)

Every argument(required or optional) has 2 things:

  1. name
  2. type (or values )

In the above DNA example, anything mentioned after /time_in will be type checked with /str which basically allows any input. So all the words after /time_in will be part of the country argument.

So the country will be "United States of America" in this case.

More on request JSON, on the next page.

Argument definitions

name: name of the argument that will be sent to your server with a value.

type: We have a separate section on types. A type in yelo is also a command that evaluates the incoming tokens like /type and whatever is the result of the evaluation that is sent to you. So if you make a strict type check here itself, you will have to handle less on your server and will only get requests when typecheck passes. If you have a loose typecheck just say '/str' it will basically do nothing and just send you the desired tokens and on your server you can clean / understand those tokens and respond back.

3. Generalized Command Definition format

This is proposed .cdf file format which is not yet in use. Right now the only way is to create .dna json file to define the command. This is a rather shorthand easier way to define your command.

/xyz:default (url0)  
/xyz:path1 (url1) name::required/optional::type/values::minwords=1::maxwords=3::words=2 ...  
/xyz:path2 (url2) {name=name2::required=required::type=/str minwords:1} {name23::required::/1word}

That's it!

Next we will learn about request and response!

results matching ""

    No results matching ""