main: add support for CLI extensions via external binaries
This adds some logic to detect and dispatch unknown subcommands to extensions available in `$PATH`. Additional commands can be implemented by adding relevant `ostree-$verb` binaries to the system. As an example, if a `/usr/bin/ostree-extcommand` extension is provided, the execution of `ostree extcommand --help` will be dispatched to that as `ostree-extcommand extcommand --help`.
This commit is contained in:
5 files changed
+140
-16
No files matched your search
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (C) 2021 Red Hat Inc.
|
||||
# SPDX-License-Identifier: LGPL-2.0+
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
echo '1..2'
|
||||
|
||||
mkdir -p ./localbin
|
||||
export PATH="./localbin/:${PATH}"
|
||||
ln -s /usr/bin/env ./localbin/ostree-env
|
||||
${CMD_PREFIX} ostree env --help >out.txt
|
||||
assert_file_has_content out.txt "with an empty environment"
|
||||
rm -rf -- localbin
|
||||
|
||||
echo 'ok CLI extension localbin ostree-env'
|
||||
|
||||
if ${CMD_PREFIX} ostree nosuchcommand 2>err.txt; then
|
||||
assert_not_reached "missing CLI extension ostree-nosuchcommand succeeded"
|
||||
fi
|
||||
assert_file_has_content err.txt "Unknown command 'nosuchcommand'"
|
||||
rm -f -- err.txt
|
||||
|
||||
echo 'ok CLI extension unknown ostree-nosuchcommand'
|
||||
Reference in new issue
Block a user