ddgr
ddgr copied to clipboard
FR/Bug: Add the instant answer when using `--json`
Not sure whether it's a bug or intentional, when using --json
, the instant answer is left out, resulting in the need to often call ddgr
twice to get json output & any instant answer
# shows one result with instant answer
ddgr -n 1 --np ip
# shows only result
ddgr -n 1 --json ip
Please raise a PR.
I'm not really sure what the best way for doing this would be. I have an implementation here:
https://github.com/kometenstaub/ddgr
Diff:
https://github.com/jarun/ddgr/compare/main...kometenstaub:ddgr:main
However, this approach changes the JSON format and would be a breaking change.
The answers from before are still a list, but the return format is a dict.
{
results: [],
instant_answer: "…",
}
instant_answer
will not be added to the dict if it is missing.