Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datasette -s/--setting option for setting nested configuration options #2156

Closed
simonw opened this issue Aug 24, 2023 · 4 comments
Closed

datasette -s/--setting option for setting nested configuration options #2156

simonw opened this issue Aug 24, 2023 · 4 comments

Comments

@simonw
Copy link
Owner

simonw commented Aug 24, 2023

I've been thinking about what it might look like to allow command-line arguments to be used to define any of the configuration options in datasette.yml, as alternative and more convenient syntax.

Here's what I've come up with:

datasette \
  -s settings.sql_time_limit_ms 1000 \
  -s plugins.datasette-auth-tokens.manage_tokens true \
  -s plugins.datasette-auth-tokens.manage_tokens_database tokens \
 mydatabase.db tokens.db

Which would be equivalent to datasette.yml containing this:

plugins:
  datasette-auth-tokens:
    manage_tokens: true
    manage_tokens_database: tokens
settings:
  sql_time_limit_ms: 1000

More details in #2143 (comment)

@simonw
Copy link
Owner Author

simonw commented Aug 24, 2023

I have an implementation in #2143 (comment) too - I'm going to land that as a PR.

@simonw
Copy link
Owner Author

simonw commented Aug 24, 2023

Oops, that was meant to be a PR. It's just a utility function though so it's safe to land already. I'll do a PR for the actual integration of it.

@simonw
Copy link
Owner Author

simonw commented Aug 24, 2023

Ran out of time for this, I'll look at the next step next week.

@simonw
Copy link
Owner Author

simonw commented Aug 28, 2023

simonw added a commit that referenced this issue Aug 28, 2023
This change updates the `-s/--setting` option to `datasette serve` to allow it to be used to set arbitrarily complex nested settings in a way that is compatible with the new `-c datasette.yml` work happening in:
- #2143

It will enable things like this:
```
datasette data.db --setting plugins.datasette-ripgrep.path "/home/simon/code"
```
For the moment though it just affects [settings](https://docs.datasette.io/en/1.0a4/settings.html) - so you can do this:
```
datasette data.db --setting settings.sql_time_limit_ms 3500
```
I've also implemented a backwards compatibility mechanism, so if you use it this way (the old way):
```
datasette data.db --setting sql_time_limit_ms 3500
```
It will notice that the setting you passed is one of Datasette's core settings, and will treat that as if you said `settings.sql_time_limit_ms` instead.
simonw added a commit that referenced this issue Aug 29, 2023
@simonw simonw closed this as completed in 85a1dfe Feb 5, 2024
simonw added a commit that referenced this issue Feb 5, 2024
simonw added a commit that referenced this issue Feb 7, 2024
Closes #2243

* Changelog for jinja2_environment_from_request and plugin_hook_slots
* track_event() in changelog
* Remove Using YAML for metadata section - no longer necessary now we show YAML and JSON examples everywhere.
* Configuration via the command-line section - #2252
* JavaScript plugins in release notes, refs #2052
* /-/config in changelog, refs #2254

Refs #2052, #2156, #2243, #2247, #2249, #2252, #2254
simonw added a commit that referenced this issue Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant