{"action":"created","issue":{"url":"https://api.github.com/repos/dbcli/mycli/issues/200","labels_url":"https://api.github.com/repos/dbcli/mycli/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/dbcli/mycli/issues/200/comments","events_url":"https://api.github.com/repos/dbcli/mycli/issues/200/events","html_url":"https://github.com/dbcli/mycli/pull/200","id":116894841,"number":200,"title":"Adds support for system-wide config file.","user":{"login":"tsroten","id":3047055,"avatar_url":"https://avatars.githubusercontent.com/u/3047055?v=3","gravatar_id":"","url":"https://api.github.com/users/tsroten","html_url":"https://github.com/tsroten","followers_url":"https://api.github.com/users/tsroten/followers","following_url":"https://api.github.com/users/tsroten/following{/other_user}","gists_url":"https://api.github.com/users/tsroten/gists{/gist_id}","starred_url":"https://api.github.com/users/tsroten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsroten/subscriptions","organizations_url":"https://api.github.com/users/tsroten/orgs","repos_url":"https://api.github.com/users/tsroten/repos","events_url":"https://api.github.com/users/tsroten/events{/privacy}","received_events_url":"https://api.github.com/users/tsroten/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dbcli/mycli/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-14T04:30:32Z","updated_at":"2015-11-15T04:46:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dbcli/mycli/pulls/200","html_url":"https://github.com/dbcli/mycli/pull/200","diff_url":"https://github.com/dbcli/mycli/pull/200.diff","patch_url":"https://github.com/dbcli/mycli/pull/200.patch"},"body":"This fixes #161 by introducing system-wide config files. Right now, only `'/etc/myclirc'` is checked, but adding other locations to the code is a simple as adding an item to a list. If the last successful file read is not a system-wide config file, then mycli checks to see if it should write the default user config file (by seeing if one exists). But, if the last successful file read was a system-wide config file, then no default user config file is created.\r\n\r\nThis cleans up and refactors some of the `ConfigObj()` code to use a generic function that handles two types of errors: config parsing errors and file permission errors.\r\n\r\nBecause logging isn't initialized before we read the config files, these two outputs are possible:\r\n```\r\n% mycli\r\nYou don't have permission to read config file '/etc/myclirc'.\r\nVersion: 1.5.2\r\nChat: https://gitter.im/dbcli/mycli\r\nMail: https://groups.google.com/forum/#!forum/mycli-users\r\nHome: http://mycli.net\r\nThanks to the contributor - Foo\r\nmysql dev@localhost:(none)>\r\n```\r\n\r\nAnd:\r\n```\r\n% mycli\r\nError parsing config file '/etc/myclirc'.\r\nRecovering partially parsed config values.\r\nVersion: 1.5.2\r\nChat: https://gitter.im/dbcli/mycli\r\nMail: https://groups.google.com/forum/#!forum/mycli-users\r\nHome: http://mycli.net\r\nThanks to the contributor - Foo\r\nmysql dev@localhost:(none)>\r\n```\r\n\r\nI'm not sure if there is a better way to deal with those messages. They aren't printed by `mycli.py` so they don't know about `click.secho()`. They are basic logging calls to the default logging handler (stderr). Can anyone think of a better way to handle this? Or are we happy with it as it is?"},"comment":{"url":"https://api.github.com/repos/dbcli/mycli/issues/comments/156779939","html_url":"https://github.com/dbcli/mycli/pull/200#issuecomment-156779939","issue_url":"https://api.github.com/repos/dbcli/mycli/issues/200","id":156779939,"user":{"login":"amjith","id":49260,"avatar_url":"https://avatars.githubusercontent.com/u/49260?v=3","gravatar_id":"","url":"https://api.github.com/users/amjith","html_url":"https://github.com/amjith","followers_url":"https://api.github.com/users/amjith/followers","following_url":"https://api.github.com/users/amjith/following{/other_user}","gists_url":"https://api.github.com/users/amjith/gists{/gist_id}","starred_url":"https://api.github.com/users/amjith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amjith/subscriptions","organizations_url":"https://api.github.com/users/amjith/orgs","repos_url":"https://api.github.com/users/amjith/repos","events_url":"https://api.github.com/users/amjith/events{/privacy}","received_events_url":"https://api.github.com/users/amjith/received_events","type":"User","site_admin":false},"created_at":"2015-11-15T04:46:55Z","updated_at":"2015-11-15T04:46:55Z","body":"An interesting side effect of this change is now I'm aware of an inefficiency. I noticed that when I launched mycli I got the `Error parsing...` message three times. Further investigation revealed we're reading it once for pager, once for prompt and once for connection details.\r\n\r\nOptimizing that should help a little bit with startup time. :)"}}