-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement pizauth revoke
.
#30
Conversation
Will check tomorrow, thanks! |
@hseg Any luck with this one? |
On Sun, Jan 07, 2024 at 12:33:04AM -0800, Laurence Tratt wrote:
@hseg Any luck with this one?
Just tested, rebases cleanly and seems to be working -- cannot distinguish
difficulties from general neomutt jankiness, but the results LGTM.
|
You _do_ want to add this to the bash completion, and I would've appreciated the
ping on testing this coming after a rebase onto master (building a package on an
off-master branch is supported in my build system, playing around with the git
history isn't (so I need to hope an automated rebase goes through)), but those
are only tangentially on-topic quibbles.
|
On Sun, Jan 07, 2024 at 12:33:04AM -0800, Laurence Tratt wrote:
@hseg Any luck with this one?
So testing ended up with me authenticating with a stale link, which pizauth
notified me of. I then revoked and restarted the authentication flow, which
worked. Am more confident that it works now.
|
If you have a suggested patch for the bash completion, I'd very happily incorporate it! |
On Sun, Jan 07, 2024 at 10:06:15AM -0800, Laurence Tratt wrote:
If you have a suggested patch for the bash completion, I'd very happily incorporate it!
You just need to copy the `$COMP_CWORD=3` case for `refresh|show` into the
`$COMP_CWORD=2` case for revoke, skipping the check for `-u`:
```
diff --git a/share/bash/completion.bash b/share/bash/completion.bash
index 70a1fc7..30e3be6 100644
--- a/share/bash/completion.bash
+++ b/share/bash/completion.bash
@@ -40,6 +40,14 @@ _pizauth()
mapfile -t COMPREPLY < \
<(compgen -W "${accounts[*]}" -- "$cur")
;;
+ revoke)
+ local accounts
+ mapfile -t accounts < <(_accounts)
+ mapfile -t COMPREPLY < \
+ <(compgen -W "${accounts[*]}" -- "$cur")
+ ;;
+ *) COMPREPLY=()
+ ;;
esac
;;
3)
```
BTW, looking at the README in <https://github.com/scop/bash-completion>, I see
they ask for completions to be installed at `pkg-config --variable
completionsdir bash-completion`, and offer the following autoconfig snippets for
it:
```m4
PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
bashcompdir="${sysconfdir}/bash_completion.d")
AC_SUBST(bashcompdir)
```
```makefile
bashcompdir = @bashcompdir@
dist_bashcomp_DATA = your-completion-file # completion files go here
```
Though in practice I see many packages hardcoding `/usr/share/bash-completion/`.
|
Currently this is local-only as OAuth2 provides no standard way of revoking remote tokens (though some providers do provide ad-hoc extensions to do so).
Co-authored-by: gesh <[email protected]>
@hseg I had to slightly tweak the whitespace, so please check that c8e5ff2 still does what you hope.
Using this should be easy, though interestingly on the Linux box I have access to it returns |
Ah, you're right -- misread the installation scripts I was looking at. The directive doesn't seem to be universally followed, though -- indeed, on my So it's up to you if you want to do things "properly" -- I can always just move |
I'm going to merge this PR, and investigate the |
On Tue, Jan 09, 2024 at 06:20:39AM -0800, Laurence Tratt wrote:
I'm going to merge this PR, and investigate the `pkg-config` aspect in another PR.
Just noticed in testing that I missed one place needing edits -- the line `local
cmds=(...)` in `share/bash/completion.bash` should have `revoke` added to it.
As it stands now, `pizauth revoke <TAB>` completes available accounts, but
`pizauth re<TAB>` doesn't mention revoke.
Checking for alternative solutions to avoid this duplication in the future, I
notice some of the programs I use use
<https://hackage.haskell.org/package/optparse-applicative>. The logic that
library uses is to have a hidden set of flags (`--bash-completion-index`,
`--bash-completion-word`) to pass the argument parsing code the current
commandline, at which point it responds with replacements/completions to offer
at the current index.
Looking around a little at the rust ecosystem, apparently there's [several
libraries in this space](https://github.com/rosetta-rs/argparse-rosetta-rs) --
one that seems to be cropping up frequently is <https://github.com/clap-rs/clap>
-- perhaps that might help?
Also, `bash-completion` offers the functions `_comp_compgen_help` and
`_comp_compgen_usage`, which are basically docopt implementations -- they parse
usage messages to construct the completions.
|
Might you be able to raise a PR with the necessary changes? |
OK, in the meantime I pushed a PKGBUILD to AUR moving the bash completion to |
Currently this is local-only as OAuth2 provides no standard way of revoking remote tokens (though some providers do provide ad-hoc extensions to do so).
Fixes #29. @hseg Please see if this works for you (I have lightly, but not yet extensively, tested it).