Open joehacksalot opened 1 month ago
This was also asked for in https://github.com/kellyjonbrazil/jc/issues/464
I would welcome a PR for and ipconfig /all
parser.
This was also asked for in #464
You're right. My bad. I was looking at issue titles and didn't see that. Let me take a look at what it'll take making a parser. Haven't done one before, and the first couple I looked at looked rather complex. If I put something together, I'll submit a PR. I do worry I don't have all the possible output for ipconfig and might miss something.
I've got the parser working outside of jc and working to tie it in. I'm struggling to understand the purpose/use of raw output. I tried looking at several other parsers and couldn't make sense of it either. Any help here would be appreciated!
Edit: Disregard. I got it.
Just for others who may read this thread - there are typically two parsing stages: parse()
and process()
parse()
should do most of the heavy lifting and get data in the schema but without doing any type conversions.
process()
should iterate over the dict
or list
object from parse()
and do the string-to-x conversions as necessary. Sometimes other fields are added here, like calculated timestamps, splitting measurement and unit fields, etc. This second stage ensures that the output matches the documented schema.
Not all parsers will have anything going on in the process()
function. These are typically very simple parsers.
Many parsers have both stages and the user can skip the process()
stage by using the --raw
cli option or the raw=True
python parameter. This can be useful if the user needs the more literal string output or if they are troubleshooting a parser issue and want to workaround or narrow down where the issue is by skipping the process()
stage.
I have merged this into dev
and it will make it into the next release.
I'm finding myself in need of an ipconfig parser and think this is likely others might find useful. Looking at the output, it looks like it might be rather simple to parse reliably compared to some of the other open parser requests I was looking at.
Here is a sample
ipconfig /all
for discussion.