Skip to content

Fix #109: connect --language and --country to export request options - #449

Open
jacalata wants to merge 3 commits into
developmentfrom
jac/109-export-language-country
Open

jacalata wants to merge 3 commits into
developmentfrom
jac/109-export-language-country

Conversation

@jacalata

@jacalata jacalata commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Closes #109.

Motivation

--language was threading through to request_options.language on
export, but --country never reached the REST API. Classic combined
the two into a BCP 47 locale (en-GB, de-DE, pt-BR) so exports
formatted numbers, dates, and currency for that region. tabcmd 2's
--country was cosmetic.

Behavior change

For users:

  • _resolve_locale() joins --language + --country into a
    lang-COUNTRY locale string when both are set; falls back to
    language alone if only that is supplied.
  • --country alone now logs a WARNING that names the ignored country
    code and drops it (matching Classic which required --language with
    --country). Previously silently dropped.
  • --country choices relaxed from the incorrectly-populated language
    codes (de|en|es|...) to any 2-letter code (upper-cased), so users
    can actually pass GB, MX, BR, etc.
  • Locale threads through apply_png_options / apply_pdf_options /
    apply_csv_options.

Test plan

  • tests/commands/test_datasources_and_workbooks_command.py — 8
    new tests cover combined locale for PNG/PDF/CSV, country-only drops
    with a warning, language-only pass-through does not warn
  • Full test suite passes

🤖 Generated with Claude Code

--language was already threading through to
request_options.language on export, but --country never reached the
REST API. tabcmd Classic combined the two into a BCP 47 locale like
en-GB or de-DE so exports formatted numbers, dates, and currency for
that region.

- Add _resolve_locale() that joins language + country when both are set,
  falls back to language alone, and drops country-only (matching Classic
  which required --language with --country).
- Route apply_png_options / apply_pdf_options / apply_csv_options
  through the helper.
- Relax --country choices from language codes to any 2-letter code
  (upper-cased), so users can pass real country codes like GB, MX, BR.

Fixes #109.
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
tabcmd
   __main__.py121212 0%
   _version.py111111 0%
   tabcmd.py151515 0%
   version.py955 44%
tabcmd/commands
   commands.py101010 0%
   constants.py771818 77%
   server.py1351818 87%
tabcmd/commands/auth
   session.py3945050 87%
tabcmd/commands/datasources_and_workbooks
   datasources_and_workbooks_command.py1691818 89%
   datasources_workbooks_views_url_parser.py14255 96%
   delete_command.py601616 73%
   export_command.py1202525 79%
   get_url_command.py1274747 63%
   publish_command.py1232828 77%
   runschedule_command.py2177 67%
tabcmd/commands/extracts
   create_extracts_command.py4288 81%
   decrypt_extracts_command.py2722 93%
   delete_extracts_command.py3766 84%
   encrypt_extracts_command.py2722 93%
   extracts.py2022 90%
   reencrypt_extracts_command.py2722 93%
   refresh_extracts_command.py481010 79%
tabcmd/commands/group
   create_group_command.py2955 83%
   delete_group_command.py2722 93%
tabcmd/commands/project
   create_project_command.py4688 83%
   delete_project_command.py3544 89%
   publish_samples_command.py3044 87%
tabcmd/commands/site
   create_site_command.py3455 85%
   delete_site_command.py2722 93%
   edit_site_command.py3822 95%
   list_command.py771212 84%
   list_sites_command.py2922 93%
tabcmd/commands/user
   add_users_command.py2955 83%
   create_site_users.py581111 81%
   create_users_command.py5999 85%
   delete_site_users_command.py4355 88%
   user_data.py2223131 86%
tabcmd/execution
   _version.py222 0%
   global_options.py12588 94%
   localize.py661111 83%
   logger_config.py6066 90%
   tabcmd_controller.py4277 83%
TOTAL288545884% 

jacalata and others added 2 commits August 7, 2026 00:00
The docstring/PR body claimed --country alone was warned about, but the
code silently dropped it. Thread the logger through _resolve_locale and
emit a warning that names the ignored country code. Adds tests for both
the warn-and-drop and don't-warn-when-language-is-set paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address country validation and rebuild the localization catalogs.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Connects --language and --country to PNG, PDF, and CSV export locales.

Changes:

  • Combines language and country into BCP 47 locales.
  • Warns when country is supplied without language.
  • Adds locale handling and test coverage.
File Summary Findings
tests/​commands/​test_datasources_and_workbooks_command.py Tests locale resolution and export options. None
tabcmd/​locales/​en/​tabcmd_messages_en.properties Adds the country-only warning message. Nit (3 votes): rebuild and commit generated catalogs.
tabcmd/​execution/​parent_parser.py Normalizes country input. Moderate (3 votes): validate exactly two ASCII letters.
tabcmd/​commands/​datasources_and_workbooks/​datasources_and_workbooks_command.py Applies resolved locales to export requests. None

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

# ISO 3166-1 alpha-2 country code (case-insensitive). Combined with --language
# to form a locale (e.g. --language en --country GB -> "en-GB"). Left
# unconstrained on choices since Classic accepts any 2-letter country code.
type=str.upper,
export.errors.white_space_workbook_view=The name of the workbook or view to export cannot include spaces. Use the normalized name of the workbook or view as it appears in the URL.
export.errors.requires_workbook_view_param=The ''{0}'' command requires a <workbook>/<view> parameter, and there must be at least one slash (/) in this parameter
export.errors.requires_valid_custom_view_uuid=The URL for custom views must contain a valid custom view uuid
export.locale.country_without_language=--country {0} was ignored: --country requires --language (e.g. --language en --country GB). Using the site''s default locale.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants