bskinn / sphobjinv

Toolkit for manipulation and inspection of Sphinx objects.inv files
https://sphobjinv.readthedocs.io
MIT License
81 stars 9 forks source link

act as textconv so can git diff inventory #295

Open msftcangoblowm opened 3 months ago

msftcangoblowm commented 3 months ago

Is your feature request related to a problem? Please describe. git can be informed on which files are binary. And then instructed how to convert the binary files into text files, so git diff can work.

git passes in the .inv file name cuz the git diff is occurring on the .inv, not on the .txt file.

sphobjinv convert plain requires a hyphen to be passed in to have the output sent to stdout. Instead would like a option flag. So then sphobjinv can act as a textconv

docs/.gitattributes

[diff "inv"]
  textconv = sphobjinv --stdout convert plain 
  binary = true

Describe the solution you'd like Provide a --stdout option flag as another means to specify the outfile hyphen.

Describe alternatives you've considered Alternative approach, which i'm using now, is to mark the inventory files as binary and not be able to use git diff

docs/.gitattributes

*.inv binary

Additional context

159 is a similar feature request, but for stdin

The difference is infile is a required positional argument whereas outfile is optional. So a --stdout flag would not change sphobjinv command line interface

perform diffs on binary files

the fallback, indicate files are binary

msftcangoblowm commented 3 months ago

The textconv config option is used to define a program for performing such a conversion. The program should take a single argument, the name of a file to convert, and produce the resulting text on stdout.

2nd paragraph from perform diffs on binary files

Didn't see The program should take a single argument. Which would necessitate an additional entrypoint to act as a textconv program

sphobjinv-textconv infile

Which can only be used with inventory files and produces plain text onto stdout

bskinn commented 3 months ago

I like this! And yeah, it should be a matter of writing a new ArgumentParser, wiring it into a new textconv function in e.g. sphobjinv.cli.core, and then adding a new entrypoint in pyproject.toml.

I probably won't be able to get to this right away -- if you're interested, feel free to put a PR together for it.

msftcangoblowm commented 3 months ago

Thank you for your enthusiastic approval for this feature. That, and your advice, are very much appreciated and what i was seeking.

This is on me. I got this. ETA 2-3 days

bskinn commented 2 weeks ago

Switching this from planned to maybe. See #296; I remain open to adding an implementation of the sphobjinv-textconv entrypoint as discussed there, though as discussed there I'm unsure whether it's necessary given that the current CLI can support git textconv functionality, albeit only with more-complex and less-readable syntax in the relevant git configuration.