CLI Reference

Command-line reference for the barangay PSGC tool: search, export, validate, batch operations, plugin enrichment, and info subcommands with examples.
Author

bendlikeabamboo

Export

barangay export

Export data to JSON or CSV.

barangay export --model flat --format json --output data.json

Options:

Parameter Type Default Required Description
--model str flat No Data model - flat or extended (basic is no longer supported)
--format, -f str json No Output format - json or csv (CSV is flat-only)
--output, -o str stdout No Output file
--as-of str - No Historical date (YYYY-MM-DD)
--plugin str - No Enable a plugin for enrichment (repeatable; only with --model flat)

Note: The legacy --model basic nested-2-level model has been removed. CSV export is only available with --model flat; CSV columns are derived from the actual records (no hardcoded 3-column header).

Examples:

# Export flat data to JSON
barangay export --model flat --format json --output data.json

# Export flat data to CSV
barangay export --model flat --format csv --output data.csv

# Export historical data
barangay export --model flat --format json --as-of "2025-07-08" --output historical.json

# Export with plugin enrichment
barangay export --model flat --plugin psgc-aux-data --format json --output enriched.json

Info

barangay info version

Show current data version.

barangay info version

barangay info stats

Show record counts per PSGC hierarchy level.

barangay info stats

barangay info list

List records at a given hierarchy level, optionally restricted to the descendants of a parent.

# List all barangays
barangay info list barangay

# List provinces within a region (name or PSGC ID; abbreviations resolve)
barangay info list province --parent "BARMM"

# List barangays under a municipality
barangay info list barangay --parent "Sitangkai"

# List all cities (HUC + ICC + component city)
barangay info list cities

Argument:

Parameter Type Required Description
level str Yes One of region, province, highly_urbanized_city, independent_component_city, component_city, municipality, submunicipality, special_geographic_area, barangay, or cities

Options:

Parameter Type Default Required Description
--parent str - No Ancestor name or PSGC ID to filter descendants

Output columns: Name, Type, PSGC ID.

This generic command replaces the removed list-regions, list-municipalities, and list-barangays commands.

History

barangay history list-dates

List available historical dates.

barangay history list-dates

barangay history search-history

Search historical data. Uses the same hierarchy-loyal table/JSON shape as barangay search.

barangay history search-history "Tongmageng" --as-of "2025-07-08"

Options:

Parameter Type Default Required Description
--as-of str - Yes Historical date (YYYY-MM-DD)
--limit, -l int 5 No Maximum number of results
--threshold, -t float 60.0 No Minimum similarity score 0-100
--level, -L str - No Post-filter results to a specific admin level
--match-hook str - No Name-levels to score against (repeatable); defaults to barangay
--format, -f str table No Output format - json or table

Example:

barangay history search-history "Tongmageng" --as-of "2025-07-08" --limit 5 --format table

barangay history export-history

Export historical data.

barangay history export-history --as-of "2025-07-08" --model flat

Options:

Parameter Type Default Required Description
--as-of str - Yes Historical date (YYYY-MM-DD)
--model str flat No Data model - flat or extended (basic removed)
--format, -f str json No Output format - json or csv (CSV is flat-only)
--output, -o str stdout No Output file

Example:

barangay history export-history --as-of "2025-07-08" --model flat --format json --output 2025-07-08.json

Cache

barangay cache info

Show cache information.

barangay cache info

barangay cache clear

Clear cache directory.

barangay cache clear

barangay cache download

Download data to cache.

barangay cache download

Options:

Parameter Type Default Required Description
--date str - No Date to download (YYYY-MM-DD)

Examples:

# Download current data
barangay cache download

# Download specific historical date
barangay cache download --date "2025-07-08"

Batch

barangay batch validate

Validate full addresses from file (one per line). Uses the same semantics as the Python validate() function (high threshold, full address match).

barangay batch validate addresses.txt

Options:

Parameter Type Default Required Description
--as-of str - No Historical date (YYYY-MM-DD)
--threshold, -t float 95.0 No Minimum score for a valid match (0-100)

Output columns: Input, Valid, Match, rphicmsgb, Score.

Example:

# addresses.txt contains one full address per line, e.g.
# Tongmageng, Sitangkai, Tawi-Tawi
barangay batch validate addresses.txt

Plugins

barangay plugins list

List available plugins with their status.

barangay plugins list

Output: Table with columns: Name, Status (enabled/disabled), Description.

barangay plugins info

Show details for a specific plugin.

barangay plugins info psgc-aux-data

Output: Table with columns: Property, Value (name, enabled, description, version, format, repository).

Raises an error if the plugin name is not found.

Help

barangay --help
barangay search --help
barangay export --help
barangay info --help
barangay history --help
barangay cache --help
barangay batch --help
barangay plugins --help

See also