Skip to content

gh67 - xts validate#71

Open
zghp wants to merge 1 commit into
developfrom
feature/gh67-xts-validate
Open

gh67 - xts validate#71
zghp wants to merge 1 commit into
developfrom
feature/gh67-xts-validate

Conversation

@zghp

@zghp zghp commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@zghp zghp self-assigned this Jun 22, 2026
@zghp zghp requested a review from a team as a code owner June 22, 2026 11:25
@zghp zghp added the enhancement New feature or request label Jun 22, 2026
Copilot AI review requested due to automatic review settings June 22, 2026 11:25
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


zghp seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@zghp zghp linked an issue Jun 22, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a built-in xts validate subcommand to validate .xts files (YAML + basic structural checks) without running commands, along with documentation and tests.

Changes:

  • Add CLI handling for xts validate <file.xts> and implement .xts file validation logic.
  • Add pytest coverage for validate success and common failure modes.
  • Document the new validate command in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
test/test_xts_all_cases.py Adds tests covering xts validate success and error cases (missing file, YAML error, invalid structure).
src/xts_core/xts.py Implements validate command routing and validation helpers for .xts syntax/structure.
README.md Documents xts validate usage and expected exit codes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xts_core/xts.py
Comment on lines +247 to +263
def _validate_xts_structure(self, node, path='root'):
if isinstance(node, dict):
for key, value in node.items():
if key == 'command':
self._validate_command_value(value, f'{path}/command')
elif isinstance(value, list):
error(
f'Invalid .xts structure at "{path}/{key}": '
'lists are not supported in XTS configuration '
'sections'
)
else:
self._validate_xts_structure(value, f'{path}/{key}')
elif isinstance(node, list):
for index, item in enumerate(node):
self._validate_xts_structure(item, f'{path}[{index}]')

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.

We should add a warning to show sections of the xts file that will be ignored by xts, because they do not contain a command key.

Comment thread src/xts_core/xts.py
Comment on lines +222 to +229
def _validate_command_string(self, value, path):
for quote_char in ('"', "'"):
if value.count(quote_char) % 2 == 1:
error(
f'Invalid .xts command string at "{path}": '
f'unbalanced {quote_char} quote'
)

Comment thread src/xts_core/xts.py
Comment on lines +281 to +283
if not os.path.exists(xts_file):
error(f'xts file does not exist: {xts_file}')

Comment thread src/xts_core/xts.py
Comment on lines +193 to +195
if remaining_args[0] == 'validate':
self._run_validate_command(remaining_args[1:])

Comment thread README.md
xts validate /path/to/file.xts
```

This command reports syntax errors clearly and exits with code `0` for valid files or `1` for invalid files.
@zghp zghp requested a review from TB-1993 June 22, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: xts validate

3 participants