Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an xmlvalidate command #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add an xmlvalidate command #34

wants to merge 2 commits into from

Conversation

djjuhasz
Copy link
Contributor

Add an xmlvalidate command to help testing the functionality from the CLI.

@djjuhasz djjuhasz force-pushed the dev/add-xmlvalidate-cmd branch from 70eb8c2 to 5605d5d Compare October 18, 2024 22:02
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.88%. Comparing base (8ea34d2) to head (5460863).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   81.88%   81.88%           
=======================================
  Files          16       16           
  Lines         436      436           
=======================================
  Hits          357      357           
  Misses         55       55           
  Partials       24       24           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@djjuhasz djjuhasz force-pushed the dev/add-xmlvalidate-cmd branch from 5605d5d to 3d926ef Compare October 18, 2024 22:06
Add `xmlvalidate/cmd/xmlvalidate.go` to allow running xmlvalidate from
the CLI for testing purposes.
@djjuhasz djjuhasz force-pushed the dev/add-xmlvalidate-cmd branch from 3d926ef to 3d650f4 Compare October 18, 2024 22:08
Copy link
Contributor

@jraddaoui jraddaoui left a comment

Choose a reason for hiding this comment

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

Thanks @djjuhasz, not sure if it adds a lot of value, but check my comments below if you find it useful.

XMLFILE Path of the XML file to be validated

OPTIONS:
--xsd PATH Path of an XSD file to validate against
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's required, I'd make it an argument too.

Copy link
Contributor Author

@djjuhasz djjuhasz Oct 21, 2024

Choose a reason for hiding this comment

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

I made it an option for two reasons:

  1. It avoids confusing the order of the XML file path and XSD file path, e.g. xmlvalidate person.xsd people.xml vs. xmlvalidate people.xml person.xsd
  2. It leaves open the option of adding a --dtd option to validate XML against a DTD file instead of an XSD

I think the first reason justifies typing the extra --xsd .

} else {
fmt.Println(out)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Recent PRs changed the xmlvalidate activity but didn't reflect those changes in the docs (parameter names, result type, how to use the XMLLintValidator). It would be nice to include a note somewhere in there about this command too, if we really want to include it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! I'll update the docs. 😊

}

// To test: `go run ./cmd --xsd testdata/person.xsd testdata/person_valid.xml`
func main() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try to follow https://artefactual.dev/docs/programming-languages/go/main/ and add some tests for this command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, okay. 👍

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