mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-02-09 22:46:04 +00:00
chasquid-util: Remove dependency on docopt-go
The docopt-go library is quite convenient, but it has been abandoned for a while :( Since we only use it for chasquid-util, this patch removes it and replaces it with a custom small parser, that is a reasonable fit for the required use cases. The patch also adds a couple of tests to increase coverage. NOTE: docopt-go accepted some undocumented behaviour, in particular the use of "-a b" instead of "-a=b". The new parser does not, so some user scripts may require updating. I think this should be rare enough not to be worth the complexity of adjusting the parser to allow it.
This commit is contained in:
@@ -8,7 +8,7 @@ init
|
||||
go build || exit 1
|
||||
|
||||
function r() {
|
||||
./chasquid-util -C .config "$@"
|
||||
./chasquid-util -C=.config "$@"
|
||||
}
|
||||
|
||||
function check_userdb() {
|
||||
@@ -44,6 +44,22 @@ if r authenticate user@domain --password=abcd > /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Interactive authentication.
|
||||
# Need to wrap the execution under "script" since the interaction requires an
|
||||
# actual TTY, and that's a fairly portable way to do that.
|
||||
if hash script 2>/dev/null; then
|
||||
if ! (echo passwd; echo passwd ) \
|
||||
| script \
|
||||
-qfec "./chasquid-util -C=.config authenticate user@domain" \
|
||||
".script-out" \
|
||||
| grep -q "Authentication succeeded";
|
||||
then
|
||||
echo interactive authenticate failed
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if ! r user-remove user@domain > /dev/null; then
|
||||
echo user-remove failed
|
||||
exit 1
|
||||
@@ -99,4 +115,9 @@ if r aliases-add alias3@notexist target > /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if r aliases-add alias4@domain > /dev/null; then
|
||||
echo aliases-add without target worked
|
||||
exit 1
|
||||
fi
|
||||
|
||||
success
|
||||
|
||||
Reference in New Issue
Block a user