diff options
author | Levente Polyak <anthraxx@archlinux.org> | 2022-09-12 01:34:08 +0200 |
---|---|---|
committer | Levente Polyak <anthraxx@archlinux.org> | 2023-05-19 22:27:12 +0200 |
commit | a8be7423efb287edd5ef80002a75a853fc0c9c1d (patch) | |
tree | 327592b654c18c8b66d0919570f7cdc973c65e04 /src | |
parent | d15bd29a9d411dedc0a0682ec54b55e079d4f00f (diff) | |
download | devtools-a8be7423efb287edd5ef80002a75a853fc0c9c1d.tar.xz |
pkgctl: add a unified command-line frontend for devtools
This is the first step of a simple and highly structured unified
interface to devtools commands in a single wrapper.
The split is based on groups like `repo`, `build` and `diff`
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/diffpkg.in | 11 | ||||
-rw-r--r-- | src/pkgctl.in | 56 | ||||
-rw-r--r-- | src/pkgrepo.in | 7 |
3 files changed, 66 insertions, 8 deletions
diff --git a/src/diffpkg.in b/src/diffpkg.in index 6d07419..4856e44 100644 --- a/src/diffpkg.in +++ b/src/diffpkg.in @@ -5,8 +5,9 @@ m4_include(lib/common.sh) usage() { - cat <<- _EOF_ - Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] [MODES] [FILE|PKGNAME...] + local -r COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} + cat <<- _EOF_ + Usage: ${COMMAND} [OPTIONS] [MODES] [FILE|PKGNAME...] Searches for a locally built package corresponding to the PKGBUILD, and downloads the last version of that package from the Pacman repositories. @@ -17,8 +18,8 @@ usage() { When given two packages, diff both packages against each other. In either case, a package name will be converted to a filename from the - cache, and diffpkg will proceed as though this filename was initially - specified. + cache, and '${COMMAND}' will proceed as though this filename was + initially specified. OPTIONS -M, --makepkg-config Set an alternate makepkg configuration file @@ -300,7 +301,7 @@ shopt -u extglob if (( $# < 2 )); then if [[ ! -f PKGBUILD ]]; then - die "This must be run in the directory of a built package.\nTry '$(basename "$0") --help' for more information." + die "This must be run in the directory of a built package.\nTry '${COMMAND} --help' for more information." fi # shellcheck source=contrib/makepkg/PKGBUILD.proto diff --git a/src/pkgctl.in b/src/pkgctl.in new file mode 100644 index 0000000..9b7d89c --- /dev/null +++ b/src/pkgctl.in @@ -0,0 +1,56 @@ +#!/bin/bash +# +# SPDX-License-Identifier: GPL-3.0-or-later + +m4_include(lib/common.sh) + +set -e + + +usage() { + local -r COMMAND=${BASH_SOURCE[0]##*/} + cat <<- _EOF_ + Usage: ${COMMAND} [COMMAND] [OPTIONS] + + Unified command-line frontend for devtools. + + COMMANDS + diff Compare package files using different modes + repo Manage Git packaging repositories and their configuration + + OPTIONS + -h, --help Show this help text +_EOF_ +} + +if (( $# < 1 )); then + usage + exit 1 +fi + +export _DEVTOOLS_COMMAND='pkgctl' + +# command checking +while (( $# )); do + case $1 in + -h|--help) + usage + exit 0 + ;; + repo) + _DEVTOOLS_COMMAND+=" $1" + shift + pkgrepo "$@" + exit 0 + ;; + diff) + _DEVTOOLS_COMMAND+=" $1" + shift + diffpkg "$@" + exit 0 + ;; + *) + die "invalid command: %s" "$1" + ;; + esac +done diff --git a/src/pkgrepo.in b/src/pkgrepo.in index c6f5951..00f46e1 100644 --- a/src/pkgrepo.in +++ b/src/pkgrepo.in @@ -9,10 +9,11 @@ source /usr/share/makepkg/util/message.sh set -e +COMMAND=${_DEVTOOLS_COMMAND:-${BASH_SOURCE[0]##*/}} usage() { cat <<- _EOF_ - Usage: ${BASH_SOURCE[0]##*/} [COMMAND] [OPTIONS] + Usage: ${COMMAND} [COMMAND] [OPTIONS] Manage Git packaging repositories and helps with their configuration according to distro specs. @@ -37,7 +38,7 @@ _EOF_ usage_clone() { cat <<- _EOF_ - Usage: ${BASH_SOURCE[0]##*/} clone [OPTIONS] [PKGNAME...] + Usage: ${COMMAND} clone [OPTIONS] [PKGNAME...] Clone Git packaging repositories from the canonical namespace. @@ -57,7 +58,7 @@ _EOF_ usage_configure() { cat <<- _EOF_ - Usage: ${BASH_SOURCE[0]##*/} configure [OPTIONS] [PATH...] + Usage: ${COMMAND} configure [OPTIONS] [PATH...] Configure Git packaging repositories according to distro specs and makepkg.conf settings. |