Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config as YAML #90

Open
chb0github opened this issue Oct 12, 2017 · 5 comments
Open

config as YAML #90

chb0github opened this issue Oct 12, 2017 · 5 comments

Comments

@chb0github
Copy link
Contributor

Hooks seem like a really cool and powerful feature. But the config syntax is a bit messy:

hook_after_down=JavaScript:printvar.js:when=after:what=down

would be much more inuitive as YAML:

events:
  hook_after_down:
    hooks:
    - script: printvars.js
      type: javascript
      properties:
        when: after
        what: down

Also, declaring JavaScript is redundant if you go by convention: .js or Groovy as .groovy

@harawata
Copy link
Member

Hi @chb0github ,

YAML might be nice, but not nice enough to complicate the implementation, but this is my personal opinion.
I appreciate your feedbacks and ideas, so please do not get me wrong. :)

declaring JavaScript is redundant if you go by convention: .js or Groovy as .groovy

The language name is declared by each implementation and Migrations just calls ScriptEngineManager#getEngineByName().
In case of JavaScript, both javascript and js should work.

@chb0github
Copy link
Contributor Author

As I read into the spec I realized exactly how this is implemented: Just taken the name given and ask the factory for the script engine with that name:

Try this:

public class A {

    public static void main( String[] args ) {

        ScriptEngineManager mgr = new ScriptEngineManager();
        List<ScriptEngineFactory> factories = mgr.getEngineFactories();

        for (ScriptEngineFactory factory : factories) {

            System.out.println("ScriptEngineFactory Info");

            String engName = factory.getEngineName();
            String engVersion = factory.getEngineVersion();
            String langName = factory.getLanguageName();
            String langVersion = factory.getLanguageVersion();

            System.out.printf("\tScript Engine: %s (%s)%n", engName, engVersion);

            List<String> engNames = factory.getNames();
            for(String name : engNames) {
                System.out.printf("\tEngine Alias: %s%n", name);
            }

            System.out.printf("\tLanguage: %s (%s)%n", langName, langVersion);

        }

    }

}

Gives you this:

cbongiorno@dvm-cbongiorno1:~$ java A
ScriptEngineFactory Info
	Script Engine: Oracle Nashorn (1.8.0_144)
	Engine Alias: nashorn
	Engine Alias: Nashorn
	Engine Alias: js
	Engine Alias: JS
	Engine Alias: JavaScript
	Engine Alias: javascript
	Engine Alias: ECMAScript
	Engine Alias: ecmascript
	Language: ECMAScript (ECMA - 262 Edition 5.1)

Any of those Aliases would work.

The documentation is a bit incomplete - So, I guess then my only ask would be to update the docs a bit to make clear it's the the Engine alias (you can even paste the above code so people can interrogate their system if trying to use other scripts)

@chb0github
Copy link
Contributor Author

The question to ask yourself about a feature request: Is it about having pretty code or a bad-ass app? I mean, I am evaluating the app, not the code. I am probably submit a PR for the job if it's gonna make it in

@h3adache
Copy link
Member

@chb0github I've been considering allowing configurations to be handled differently for a while, including allowing overrides (would be great for different environments that mostly share the same values) and allowing different configuration syntax so a PR would definitely be interesting. As with any PR, we can't guarantee that it would make it in but at least it opens the discussion.

@chb0github
Copy link
Contributor Author

Is Java 8 allowed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants