{"id":1421,"library":"cligj","title":"cligj - Click parameters for GeoJSON CLIs","description":"cligj provides a collection of reusable Click parameter and option decorators specifically designed for building command-line interfaces that interact with GeoJSON data. It simplifies handling GeoJSON input/output, feature processing, and related geospatial concerns within Click applications. The current version is 0.7.2, and it maintains a stable release cadence typical for a mature utility library.","status":"active","version":"0.7.2","language":"en","source_language":"en","source_url":"https://github.com/mapbox/cligj","tags":["geojson","cli","click","geospatial","mapbox"],"install":[{"cmd":"pip install cligj","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for creating command-line interfaces.","package":"click","optional":false},{"reason":"Used for parsing and serializing GeoJSON data structures.","package":"geojson","optional":false}],"imports":[{"symbol":"features_in_info","correct":"from cligj import features_in_info"},{"symbol":"io_in_info","correct":"from cligj import io_in_info"},{"note":"old_precision_opt is deprecated in favor of precision_opt.","wrong":"from cligj import old_precision_opt","symbol":"precision_opt","correct":"from cligj import precision_opt"},{"symbol":"use_rs_opt","correct":"from cligj import use_rs_opt"},{"symbol":"interleaved_opt","correct":"from cligj import interleaved_opt"}],"quickstart":{"code":"import click\nimport json\nimport sys\nfrom cligj import features_in_info\n\n@click.command()\n@features_in_info\ndef cli(src_features):\n    \"\"\"\n    Reads GeoJSON features from stdin, adds a feature index to properties,\n    and writes the modified features to stdout as a GeoJSON sequence.\n\n    Usage example:\n    echo '{\"type\":\"Feature\",\"properties\":{},\"geometry\":null}' | python your_script.py\n    \"\"\"\n    for f, i in src_features:\n        f['properties']['f_idx'] = i['f_idx']\n        click.echo(json.dumps(f))\n\nif __name__ == '__main__':\n    cli()","lang":"python","description":"This quickstart demonstrates how to use `cligj.features_in_info` to create a Click command that reads GeoJSON features from standard input, adds a new property indicating the feature's index in the input stream, and writes the modified features as a GeoJSON sequence to standard output. It's a common pattern for processing streamable GeoJSON data."},"warnings":[{"fix":"Replace `cligj.old_precision_opt()` with `cligj.precision_opt()` in your Click commands to use the clearer and officially supported option.","message":"The `cligj.old_precision_opt` decorator is deprecated. While still functional, it's recommended to switch to `cligj.precision_opt` for explicit control over GeoJSON floating-point precision.","severity":"deprecated","affected_versions":"0.5.0 and later"},{"fix":"Use `features_in_info` when your command processes GeoJSON features one by one. Use `io_in_info` when your command expects a single GeoJSON object or needs direct control over the input/output streams for tasks like validation or transformation of the entire GeoJSON structure.","message":"Users often confuse `cligj.features_in_info` and `cligj.io_in_info`. `features_in_info` is for iterating individual GeoJSON features, typically from a FeatureCollection or a GeoJSON sequence. `io_in_info` provides file-like objects for the entire input/output stream, suitable for commands that read or write a single GeoJSON object or need byte-level control.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Develop new applications and maintain existing ones on Python 3 (preferably 3.8+). If you must interact with legacy Python 2 code, ensure thorough testing and be prepared for potential maintenance challenges.","message":"While `cligj` technically supports Python 2.7, Python 2 reached End-of-Life in 2020. New projects and ongoing development should exclusively target Python 3. Although the library's `requires_python` range supports 2.7, relying on it for new work is discouraged and may lead to compatibility issues with other modern dependencies.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}