Closed whjum closed 6 months ago
Thanks, I think this is a valid use case for info
command.
Instead of adding a new query
, I'm thinking adding a --format=json
flag to info
, which output in JSON format, then we can use leetgo info 1 | jq '.slug'
to extract any field you need.
What do you think?
That works as well and maybe easier to implement.
I am thinking instead of using --format=json
, a bool flag --raw
might be good enough? If you would like to support more than one output formats, probably a string flag will be helpful.
--format=json
is more like a convention, many tools support raw output using this flag, --raw
is not that common.
No problem. I have some idea and probably can create a pull request to implement that. If you would like to do it yourself, I can also wait for a new release :)
I would like to welcome a new contributor 😄
The original
info
command's ouput works well with a human reader. However, it is not working well with cli command as the user need to remove formatting character themselves to obtain the actual data. For example:In the above use case, I think a
query
alike command that prints unformatted output with property filter likeslug
,title
,tags
,testcase
,etc will be helpful.The query could using the following format:
leetgo query qid [property]
. For example:I created a fork to demo one draft of the
query
command. There should be a better way to map the property of the question struct than the naive switch function. If you have a better approach, I am happy to adapt that.Kindly let me know if you are interested in adding this command or there might be some better approaches! I am happy to be of help if possible.
Also, thank you sincerely for this wonderful tool! It makes my life a lot eaiser :)