{"action":"created","issue":{"url":"https://api.github.com/repos/bjorn/tiled/issues/941","repository_url":"https://api.github.com/repos/bjorn/tiled","labels_url":"https://api.github.com/repos/bjorn/tiled/issues/941/labels{/name}","comments_url":"https://api.github.com/repos/bjorn/tiled/issues/941/comments","events_url":"https://api.github.com/repos/bjorn/tiled/issues/941/events","html_url":"https://github.com/bjorn/tiled/issues/941","id":75630355,"number":941,"title":"Allow setting the working directory for commands","user":{"login":"bjorn","id":531764,"avatar_url":"https://avatars.githubusercontent.com/u/531764?v=3","gravatar_id":"","url":"https://api.github.com/users/bjorn","html_url":"https://github.com/bjorn","followers_url":"https://api.github.com/users/bjorn/followers","following_url":"https://api.github.com/users/bjorn/following{/other_user}","gists_url":"https://api.github.com/users/bjorn/gists{/gist_id}","starred_url":"https://api.github.com/users/bjorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjorn/subscriptions","organizations_url":"https://api.github.com/users/bjorn/orgs","repos_url":"https://api.github.com/users/bjorn/repos","events_url":"https://api.github.com/users/bjorn/events{/privacy}","received_events_url":"https://api.github.com/users/bjorn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bjorn/tiled/labels/Feature","name":"Feature","color":"6b7a22"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2015-05-12T14:54:14Z","updated_at":"2016-08-31T11:06:48Z","closed_at":null,"body":"It would be nice if the working directory could be specified for the custom commands.\r\n\r\nSuggested magic variables:\r\n\r\n* `%executablePath` - the path of the executable that's supposed to be run\r\n* `%mapPath` - the path of the current map file\r\n\r\nOriginally requested at issue #940."},"comment":{"url":"https://api.github.com/repos/bjorn/tiled/issues/comments/243731756","html_url":"https://github.com/bjorn/tiled/issues/941#issuecomment-243731756","issue_url":"https://api.github.com/repos/bjorn/tiled/issues/941","id":243731756,"user":{"login":"zcabjro","id":9289207,"avatar_url":"https://avatars.githubusercontent.com/u/9289207?v=3","gravatar_id":"","url":"https://api.github.com/users/zcabjro","html_url":"https://github.com/zcabjro","followers_url":"https://api.github.com/users/zcabjro/followers","following_url":"https://api.github.com/users/zcabjro/following{/other_user}","gists_url":"https://api.github.com/users/zcabjro/gists{/gist_id}","starred_url":"https://api.github.com/users/zcabjro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcabjro/subscriptions","organizations_url":"https://api.github.com/users/zcabjro/orgs","repos_url":"https://api.github.com/users/zcabjro/repos","events_url":"https://api.github.com/users/zcabjro/events{/privacy}","received_events_url":"https://api.github.com/users/zcabjro/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T11:06:48Z","updated_at":"2016-08-31T11:06:48Z","body":"Any reason this wouldn't work for map path? (command.cpp)\r\n```C++\r\n\r\nQString Command::finalCommand() const\r\n{\r\n    QString finalCommand = command;\r\n\r\n    // Perform variable replacement\r\n    if (MapDocument *mapDocument = DocumentManager::instance()->currentDocument()) {\r\n        const QString fileName = mapDocument->fileName();\r\n\r\n        finalCommand.replace(QLatin1String(\"%mapfile\"),\r\n                             QString(QLatin1String(\"\\\"%1\\\"\")).arg(fileName));\r\n\r\n       QFileInfo fileInfo(fileName);\r\n       QString mapPath = fileInfo.absolutePath();\r\n       finalCommand.replace(\r\n           QLatin1String(\"%mapPath\"),\r\n           QString(QLatin1String(\"\\\"%1\\\"\")).arg(absPath));\r\n\r\n        //...\r\n    }\r\n\r\n    return finalCommand;\r\n}\r\n```"}}
{"actor":{"display_login":"zcabjro"}}