| #!/bin/bash | |
| # Copyright 2018 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| #### CATEGORY=Other | |
| ### forward commands to vendor/*/scripts/devshell | |
| ## usage: fx vendor <vendor-dir> [command] | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/fx-cmd-locator.sh || exit $? | |
| function main { | |
| if [[ $# -lt 2 ]]; then | |
| fx-command-help | |
| echo >&2 "commands: " | |
| for d in "${FUCHSIA_DIR}"/vendor/*; do | |
| # list all subcommands with summaries, grouped by categories | |
| commands vendor "$(basename "$d")" | xargs awk \ | |
| -v hide_contrib=${hide_contrib} \ | |
| -v show_deprecated=${show_deprecated} \ | |
| -f "${FUCHSIA_DIR}/scripts/fx-help.awk" | |
| done | |
| return 1 | |
| fi | |
| vendor_name="$1" | |
| command_name="$2" | |
| command_path="$(commands vendor "${vendor_name}" "${command_name}")" | |
| # expand metadata if it's a "*.fx" file | |
| command_path=( $(find_exec_from_path "${command_path}") ) | |
| if [[ ! -x "${command_path[0]}" ]]; then | |
| echo >&2 "command ${command_name} not found on vendor ${vendor_name}!" | |
| return 1 | |
| fi | |
| shift | |
| shift | |
| exec "${command_path[@]}" "$@" | |
| } | |
| main "$@" |