For future reference, if you want to replicate a git-like man page UX (using less as the pager) the trick is defining custom commands with lesskey[0]. You can specify the exit status of the "quit" action to pass the information back to the calling script.
[0] https://www.freebsd.org/cgi/man.cgi?query=lesskey&sektion=1