import { Command } from '@cliffy/command'
import { listRegions } from '../shared/regions.ts'

export const listCmd = new Command()
  .name('list')
  .description('List available Geofabrik region slugs.')
  .option('--search <term:string>', 'Filter results by search term.')
  .action(async ({ search }) => {
    const regions = await listRegions()
    const filtered = search
      ? regions.filter((r) => r.includes(search))
      : regions
    for (const r of filtered) console.log(r)
    console.log(`\n${filtered.length} region(s)`)
  })
