bskinn / sphobjinv

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

act as textconv so can git diff inventory #295

Open msftcangoblowm opened 3 weeks ago

msftcangoblowm commented 3 weeks 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 weeks 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 weeks 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 weeks 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