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 extract CLI command #13

Open
simonw opened this issue Mar 7, 2024 · 2 comments
Open

datasette extract CLI command #13

simonw opened this issue Mar 7, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Collaborator

simonw commented Mar 7, 2024

So you can run extract on the CLI in addition to through the web UI.

@simonw simonw added the enhancement New feature or request label Mar 7, 2024
@simonw
Copy link
Collaborator Author

simonw commented Mar 7, 2024

I'm deleting the prototype code for this for the moment:

@click.command()
@click.argument(
    "database",
    type=click.Path(file_okay=True, dir_okay=False, allow_dash=False),
    required=True,
)
@click.argument("table", required=True)
def extract(database, table):
    click.echo("Will extract to {} in {}".format(table, database))


@hookimpl
def register_commands(cli):
    cli.add_command(extract, name="extract")

And test_cli.py:

from datasette.cli import cli
from click.testing import CliRunner


def test_extract_command():
    runner = CliRunner()
    result = runner.invoke(cli, ["extract", "database", "table"])
    assert result.exit_code == 0
    assert result.output == "Will extract to table in database\n"

@hcarter333
Copy link

When this enhancement exists, it will fix the issue I'm seeing. I'm parsing through the General Exam Ham Radio Question Pool.

ChatGPT keeps stopping for a variety of reasons. Then,

  1. I delete the input its already processed.
  2. I start it again
  3. More questions are parsed correctly into the database till the next stop

With the CLI, I could turn 1 - 3 into a loop and crank along :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants