From 6aab06e6ec64bf8d3ac088d6ad1f0c5f5c9116cb Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Tue, 15 Feb 2022 12:24:18 -0500 Subject: [PATCH] Run cog and add some help text. --- docs/cli-reference.rst | 51 ++++++++++++++++++++++++++++++++++++++++-- sqlite_utils/cli.py | 20 ++++++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/docs/cli-reference.rst b/docs/cli-reference.rst index 3359d5b..5497259 100644 --- a/docs/cli-reference.rst +++ b/docs/cli-reference.rst @@ -772,8 +772,10 @@ See :ref:`cli_create_database`. sqlite-utils create-database trees.db Options: - --enable-wal Enable WAL mode on the created database - -h, --help Show this message and exit. + --enable-wal Enable WAL mode on the created database + --init-spatialite Enable SpatiaLite on the created database + --load-extension TEXT SQLite extensions to load + -h, --help Show this message and exit. create-table @@ -1226,4 +1228,49 @@ See :ref:`cli_drop_view`. -h, --help Show this message and exit. +add-geometry-column +=================== + +:: + + Usage: sqlite-utils add-geometry-column [OPTIONS] DB_PATH TABLE COLUMN_NAME + + Add a SpatiaLite geometry column to an existing table. Requires SpatiaLite + extension. + + By default, this command will try to load the SpatiaLite extension from usual + paths. To load it from a specific path, use --load-extension. + + Options: + -t, --type [POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION|GEOMETRY] + Specify a geometry type for this column. + [default: GEOMETRY] + --srid INTEGER Spatial Reference ID. See + https://spatialreference.org for details on + specific projections. [default: 4326] + --dimensions TEXT Coordinate dimensions. Use XYZ for three- + dimensional geometries. + --not-null Add a NOT NULL constraint. + --load-extension TEXT SQLite extensions to load + -h, --help Show this message and exit. + + +create-spatial-index +==================== + +:: + + Usage: sqlite-utils create-spatial-index [OPTIONS] DB_PATH TABLE COLUMN_NAME + + Create a spatial index on a SpatiaLite geometry column. The table and geometry + column must already exist before trying to add a spatial index. + + By default, this command will try to load the SpatiaLite extension from usual + paths. To load it from a specific path, use --load-extension. + + Options: + --load-extension TEXT SQLite extensions to load + -h, --help Show this message and exit. + + .. [[[end]]] diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 7a827ba..30f904e 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -2746,10 +2746,24 @@ To load it from a specific path, use --load-extension.""", case_sensitive=False, ), default="GEOMETRY", + help="Specify a geometry type for this column.", + show_default=True, ) -@click.option("--srid", type=int, default=4326) -@click.option("--dimensions", "coord_dimension", type=str, default="XY") -@click.option("--not-null", "not_null", is_flag=True) +@click.option( + "--srid", + type=int, + default=4326, + show_default=True, + help="Spatial Reference ID. See https://spatialreference.org for details on specific projections.", +) +@click.option( + "--dimensions", + "coord_dimension", + type=str, + default="XY", + help="Coordinate dimensions. Use XYZ for three-dimensional geometries.", +) +@click.option("--not-null", "not_null", is_flag=True, help="Add a NOT NULL constraint.") @load_extension_option def add_geometry_column( db_path,