You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--functions can take filenames, can be used multiple times (#681)
Closes#659
The --functions option now accepts:
- File paths ending in .py (e.g., --functions my_funcs.py)
- Multiple invocations (e.g., --functions foo.py --functions 'def bar(): ...')
- Inline Python code (existing behavior)
Implementation follows the same pattern as llm's --functions flag
(simonw/llm@a880c123).
Changes:
- Added multiple=True to --functions Click option in query, bulk, and memory commands
- Modified _register_functions() to detect and read .py files
- Updated _maybe_register_functions() to iterate over multiple function sources
- Removed unused bytes/bytearray handling
- Added comprehensive tests for file paths and multiple invocations
- Updated documentation with examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Shorter help for --functions
---------
Co-authored-by: Claude <[email protected]>
Copy file name to clipboardExpand all lines: docs/cli.rst
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -368,6 +368,22 @@ This example defines a function which extracts the domain from a URL:
368
368
369
369
Every callable object defined in the block will be registered as a SQL function with the same name, with the exception of functions with names that begin with an underscore.
370
370
371
+
You can also pass the path to a Python file containing function definitions:
372
+
373
+
.. code-block:: bash
374
+
375
+
sqlite-utils query sites.db "select url, domain(url) from urls" --functions functions.py
376
+
377
+
The ``--functions`` option can be used multiple times to load functions from multiple sources:
378
+
379
+
.. code-block:: bash
380
+
381
+
sqlite-utils query sites.db "select url, domain(url), extract_path(url) from urls" \
0 commit comments