Introduce flask-less CLI interface (e.g. for programmatic DB access) #1909
+85
−35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Resolves #1690.
(Successor of https://github.com/tiny-pilot/tinypilot-pro/pull/1602.)
This PR introduces a new, internal Flask-less CLI entrypoint to our app, for programmatic access of certain features (mainly DB-related).
As a first use-case, it migrates the
streaming-modeCLI command, mainly to demonstrate how this is intended to be used. We’ll soon add another command for retrieving the serial settings. In a subsequent step, we can also migrate the last remaining command for activating a license and thereby sunset the Flask CLI entrypoint altogether. (I’d create a separate ticket for that.)Notes
app/cli). That way, we hopefully have a clearer separation from the web app, and we are also a bit more flexible to structure the code nicely.@commandannotation to make it convenient to register commands. My thinking is not to go overboard with this, though – e.g., I’d not expand this mechanism to include arg-parsing etc., as it would then probably make more sense to rather keep the Flask CLI or introduce another framework. The main intention of@commandis to have all command-related code closely together, as opposed to having to define the function in one place and then “register” it in a second. Since the whole CLI is more of an internal helper utility, I think it’s fair to keep the whole structure basic.