litestream
litestream copied to clipboard
If -exec is used after the replicate positional arguments it throws a confusing error
This works fine:
% litestream replicate \
-exec "datasette -h 0.0.0.0 -p 8042 notebook.db" \
notebook.db \
"s3://my-litestream-bucket/notebook.db"
But if you put the -exec option AFTER the positional arguments (which is usually how I use CLI tools - positional arguments first, options second) you instead get a confusing error message:
% litestream replicate \
notebook.db \
"s3://my-litestream-bucket/notebook.db" \
-exec "datasette -h 0.0.0.0 -p 8042 notebook.db"
litestream v0.3.6
replica url scheme required: -exec
I'd like it if -exec worked after the other arguments, but an alternative fix would be to improve that error message, maybe to:
-exec should be positioned before DB_PATH and REPLICA_URL
I just spotted that litestream replicate --help does provide additional clues here:
% litestream replicate --help
The replicate command starts a server to monitor & replicate databases.
You can specify your database & replicas in a configuration file or you can
replicate a single database file by specifying its path and its replicas in the
command line arguments.
Usage:
litestream replicate [arguments]
litestream replicate [arguments] DB_PATH REPLICA_URL [REPLICA_URL...]
Thanks for reporting the issue, @simonw. I'm surprised to see that Go's built-in flag package doesn't handle flags after the positional args (https://play.golang.org/p/uWQiOrWIK18). I always assumed it did.
I don't necessarily want to add in a third party dependency like cobra just to add support for this but I can fix up the error message so it's more clear. I could potentially rewrite the args list to move flags to the beginning but that seems like it could have edge cases.
Want to +1, had the same issue and found the solution here.