simonw / sqlite-utils

Python CLI utility and library for manipulating SQLite databases
https://sqlite-utils.datasette.io
Apache License 2.0
1.62k stars 109 forks source link

Make as many examples in the CLI docs as possible copy-and-pastable #551

Closed simonw closed 1 year ago

simonw commented 1 year ago

e.g. in this section:

https://sqlite-utils.datasette.io/en/stable/cli.html#running-queries-directly-against-csv-or-json

image

The little copy button will also copy the $ which breaks the examples when copied.

simonw commented 1 year ago

I wrote the docs like this because early examples include both the command and its output:

https://sqlite-utils.datasette.io/en/stable/cli.html#returning-json

image
simonw commented 1 year ago

I could split them up into two blocks like this:

image

I do miss the visual indication that one of these is the command and one is the output though.

simonw commented 1 year ago

Another option:

image

That's using this markup:

Newline-delimited JSON
~~~~~~~~~~~~~~~~~~~~~~

Use ``--nl`` to get back newline-delimited JSON objects:

.. code-block:: bash

    sqlite-utils dogs.db "select * from dogs" --nl

.. code-block:: output

    {"id": 1, "age": 4, "name": "Cleo"}
    {"id": 2, "age": 2, "name": "Pancakes"}

And this extra CSS:

.highlight-output .highlight {
  border-left: 9px solid #30c94f;
}
simonw commented 1 year ago

Put this in a PR so I can preview it:

simonw commented 1 year ago

This page has all of the changes: https://sqlite-utils--553.org.readthedocs.build/en/553/cli.html#running-sql-queries

simonw commented 1 year ago

Now live at https://sqlite-utils.datasette.io/en/latest/cli.html