aboutsummaryrefslogtreecommitdiff
path: root/src/cpt-list
blob: 4eb7cf61a681709d9e5b474a7e54f393115958ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh -ef
# List installed packages

parser_definition() {
    setup REST help:usage -- \
        "usage: ${0##*/} [-c] pkg..." \
        "or:    ${0##*/} -C pkg true-statement false-statement"
    msg -- '' 'Options:'
    flag CURRENT -c --current -- "Use the current directory as a package"
    param PKG    -C --check label:"    -C,--check PKG TRUE FALSE" -- \
          "Check if PKG exists and return the string of TRUE if"\
          "it exists, and the string of FALSE if it doesn't." \
          "Useful for optional packaging."
    global_options
}

if [ -f ./cpt-lib ]; then . ./cpt-lib; else . cpt-lib; fi

if [ "$PKG" ]; then
    if pkg_list "$PKG" >/dev/null 2>&1; then
        printf %s "$1"
    else
        printf %s "$2"
    fi
else
[ "$CURRENT" ] && set -- "${PWD##*/}"

pkg_list "$@"
fi