{"html_url": "https://github.com/simonw/datasette/issues/1998#issuecomment-1398768399", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1998", "id": 1398768399, "node_id": "IC_kwDOBm6k_c5TX4MP", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-20T18:19:06Z", "updated_at": "2023-01-20T18:19:06Z", "author_association": "OWNER", "body": "Simplest solution would be to ditch the `version_option` decorator and roll a custom option based on it instead, imitating what this code does:\r\n\r\nhttps://github.com/pallets/click/blob/7586834cab38c5592d9d6de3ee0ebe75d4353bfb/src/click/decorators.py#L413-L524", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1551113681, "label": "`datasette --version` should also show the SQLite version"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1998#issuecomment-1398767813", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1998", "id": 1398767813, "node_id": "IC_kwDOBm6k_c5TX4DF", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-20T18:18:27Z", "updated_at": "2023-01-20T18:18:27Z", "author_association": "OWNER", "body": "Fell down a bit of a rabbit hole trying to figure out how to get Click's `version_option()` to evaluate a custom message. Got this far:\r\n\r\n```python\r\nclass _VersionMessage(UserString):\r\n @property\r\n def data(self):\r\n return \"%(prog)s, version %(version)s (SQLite {})\".format(\r\n sqlite3.connect(\":memory:\").execute(\"select sqlite_version()\").fetchone()[0]\r\n )\r\n\r\n @data.setter\r\n def data(self, value):\r\n pass\r\n\r\n\r\n@click.group(cls=DefaultGroup, default=\"serve\", default_if_no_args=True)\r\n@click.version_option(version=__version__, message=_VersionMessage(\"\"))\r\ndef cli():\r\n \"\"\"\r\n Datasette is an open source multi-tool for exploring and publishing data\r\n\r\n \\b\r\n About Datasette: https://datasette.io/\r\n Full documentation: https://docs.datasette.io/\r\n \"\"\"\r\n```\r\nBut now:\r\n\r\n```\r\n% datasette --version\r\n%(prog)s, version %(version)s (SQLite 3.40.1)\r\n```\r\n\r\nI was trying to avoid running that `select sqlite_version()` thing unless the `--version` option was used.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1551113681, "label": "`datasette --version` should also show the SQLite version"}, "performed_via_github_app": null}