home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1398767813

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/1998#issuecomment-1398767813 https://api.github.com/repos/simonw/datasette/issues/1998 1398767813 IC_kwDOBm6k_c5TX4DF 9599 2023-01-20T18:18:27Z 2023-01-20T18:18:27Z OWNER

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:

```python class _VersionMessage(UserString): @property def data(self): return "%(prog)s, version %(version)s (SQLite {})".format( sqlite3.connect(":memory:").execute("select sqlite_version()").fetchone()[0] )

@data.setter
def data(self, value):
    pass

@click.group(cls=DefaultGroup, default="serve", default_if_no_args=True) @click.version_option(version=version, message=_VersionMessage("")) def cli(): """ Datasette is an open source multi-tool for exploring and publishing data

\b
About Datasette: https://datasette.io/
Full documentation: https://docs.datasette.io/
"""

``` But now:

% datasette --version %(prog)s, version %(version)s (SQLite 3.40.1)

I was trying to avoid running that select sqlite_version() thing unless the --version option was used.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
1551113681  
Powered by Datasette · Queries took 0.965ms · About: github-to-sqlite