{"action":"created","issue":{"url":"https://api.github.com/repos/Wyamio/Wyam/issues/237","repository_url":"https://api.github.com/repos/Wyamio/Wyam","labels_url":"https://api.github.com/repos/Wyamio/Wyam/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/Wyamio/Wyam/issues/237/comments","events_url":"https://api.github.com/repos/Wyamio/Wyam/issues/237/events","html_url":"https://github.com/Wyamio/Wyam/pull/237","id":134266153,"number":237,"title":"Ability to pass CLI args to config","user":{"login":"miere43","id":3995549,"avatar_url":"https://avatars.githubusercontent.com/u/3995549?v=3","gravatar_id":"","url":"https://api.github.com/users/miere43","html_url":"https://github.com/miere43","followers_url":"https://api.github.com/users/miere43/followers","following_url":"https://api.github.com/users/miere43/following{/other_user}","gists_url":"https://api.github.com/users/miere43/gists{/gist_id}","starred_url":"https://api.github.com/users/miere43/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miere43/subscriptions","organizations_url":"https://api.github.com/users/miere43/orgs","repos_url":"https://api.github.com/users/miere43/repos","events_url":"https://api.github.com/users/miere43/events{/privacy}","received_events_url":"https://api.github.com/users/miere43/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-17T12:29:02Z","updated_at":"2016-02-17T18:19:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Wyamio/Wyam/pulls/237","html_url":"https://github.com/Wyamio/Wyam/pull/237","diff_url":"https://github.com/Wyamio/Wyam/pull/237.diff","patch_url":"https://github.com/Wyamio/Wyam/pull/237.patch"},"body":"Currently works like that: `wyam.exe --pass define --pass key=value --pass Key=Value`\r\n- key/values are case-sensitive\r\n- if you pass just a key, value will be null\r\n- can be accessed from config.wyam using `EngineMetadata` variable (type `Dictionary<string, string>`)\r\n- you **can't** pass like that: `wyam.exe --pass \"key=value,key2=value2\"`\r\n- no shortcut for command line command\r\n- you can escape `=` key by writing backslash before it: `this\\=is_key` => `KeyValuePair<string, string>(\"this=is_key\", null)`;\r\n\r\n### Some thoughts\r\n- you still can't get other command like args like `--watch` or `--preview`\r\n- you don't know is metadata truly passed because if metadata key is invalid this is not passed to `EngineMetadata` and just being dropped. You can see a warning in CLI, but if you are executing Wyam from elsewhere (from another program) you can't get a warning. **Solution**: add a switch to make Wyam stop executing if key was dropped and create new return code."},"comment":{"url":"https://api.github.com/repos/Wyamio/Wyam/issues/comments/185333476","html_url":"https://github.com/Wyamio/Wyam/pull/237#issuecomment-185333476","issue_url":"https://api.github.com/repos/Wyamio/Wyam/issues/237","id":185333476,"user":{"login":"daveaglick","id":1020407,"avatar_url":"https://avatars.githubusercontent.com/u/1020407?v=3","gravatar_id":"","url":"https://api.github.com/users/daveaglick","html_url":"https://github.com/daveaglick","followers_url":"https://api.github.com/users/daveaglick/followers","following_url":"https://api.github.com/users/daveaglick/following{/other_user}","gists_url":"https://api.github.com/users/daveaglick/gists{/gist_id}","starred_url":"https://api.github.com/users/daveaglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daveaglick/subscriptions","organizations_url":"https://api.github.com/users/daveaglick/orgs","repos_url":"https://api.github.com/users/daveaglick/repos","events_url":"https://api.github.com/users/daveaglick/events{/privacy}","received_events_url":"https://api.github.com/users/daveaglick/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T18:19:31Z","updated_at":"2016-02-17T18:19:31Z","body":"> I think CLI passed metadata shouldn't belong to document\r\n\r\nI can envision use cases where it would be helpful, and I can see some where it would actually be bad. Perhaps the best approach is to leave it as you wrote it and then consider how to satisfy the case where you want metadata do flow from the CLI to the documents in a separate issue. I could see either adding another flag or engine method that essentially copies metadata from the `EngineMetadata` to the `InitialMetadata` or adding an extra CLI option that does initial metadata instead of engine metadata. Let's not worry about that for now...\r\n\r\n> Should Wyam stop execution when invalid meta passed\r\n\r\nMy gut says yes. Wyam used to be more forgiving of errors, but that doesn't make a lot of sense for a generator. If something is wrong, that means there's unexpected behavior. Especially if it's something like data you're supplying over the command line. If there's something off with it, I think we've got to kill the build.\r\n\r\n> `EngineMetadata` should be of type `Dictionary<string, string>` or IMetadata instead?\r\n\r\nAgree there is a lot of cool conversion report in the built-in metadata. However, it's also a big surface area to implement in order to get that support. I would say just leave it as a dictionary for now. What's more important is that we can get the values out exactly as they were specified on the command line. After that, the configuration script (or embedded host) should operate on the string values as needed."}}