unicesi / amelia

:airplane: DSL for deploying distributed systems, with custom commands to compile and execute FraSCAti applications
GNU Lesser General Public License v3.0
2 stars 3 forks source link

Implement a standard (command) extensibility mechanism #40

Open jachinte opened 8 years ago

jachinte commented 8 years ago

Amelia allows replacing the built-in commands with method calls returning CommandDescriptor objects. However, it is not totally integrated with the language. A good option for more command-like extensibility would be allowing the user to define its own commands. It wouldn't be much difference with regard to the current implementation, although a new kind of statement or type declaration should be introduced. For instance:

subsystem Test {
    define postgres (String action, String db, String user, String pass): [ 
        return Utility.execOnPostgres(action, db, user, pass)
    ]
    define ls (String directory): [
        return Commands.generic("ls " + directory);
    ]
    ...
    on host {
        init:
            postgres "start" "postgres" "1234"
            ls "/tmp"
    }
}

Also a good thing would be to remove the need for using quotes to specify command arguments, although that can be difficult to validate (because of grammar ambiguities).