xref: /nrf52832-nimble/rt-thread/tools/kconfig-frontends/frontends/kconfig.in (revision 104654410c56c573564690304ae786df310c91fc)
1#!/usr/bin/env bash
2
3LIST="@KCFG_LIST@"
4
5main() {
6    local kcfg="${1}"; shift
7    local k
8
9    case "${kcfg}" in
10    "")         error "what should I do (see -h)?\n";;
11    -h|--help)  help; exit 0;;
12    -*)         error "no such option '%s'\n" "${kcfg}";;
13    esac
14
15    for k in ${LIST}; do
16        if [ "${kcfg}" = "${k}" ]; then
17            exec kconfig-${kcfg} "${@}"
18            error "cannot execute tool '%s'\n" "${kcfg}"
19        fi
20    done
21    error "no such tool '%s'\n" "${kcfg}"
22}
23
24help() {
25    cat <<-_EOF_
26NAME
27    kconfig - meta-frontend to kconfig tools
28
29SYNOPSIS
30    kconfig -h|--help
31    kconfig <kconfig-tool> [option ...]
32
33DESCRIPTION
34    kconfig is the meta-frontend to all other kconfig tools:
35        ${LIST}
36
37    The acceptable options depend on what tool is being called.
38_EOF_
39}
40
41error() {
42    local fmt="${1}"; shift
43
44    printf "kconfig: ${fmt}" "${@}" >&2
45    exit 1
46}
47
48main "${@}"
49