File:  [Coherent Logic Development] / freem / scripts / fmd
Revision 1.3: download - view: text, annotated - select for diffs
Mon Apr 7 04:01:47 2025 UTC (3 days, 23 hours ago) by snw
Branches: MAIN
CVS tags: HEAD
Fix output bug in fmd help

#!/usr/bin/env bash

#
#   $Id: fmd,v 1.3 2025/04/07 04:01:47 snw Exp $
#    FreeM dev script wrapper
#
#  
#   Author: Serena Willis <snw@coherent-logic.com>
#    Copyright (C) 2025 Coherent Logic Development LLC
#
#
#   This file is part of FreeM.
#
#   FreeM is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   FreeM is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero Public License for more details.
#
#   You should have received a copy of the GNU Affero Public License
#   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
#
#   $Log: fmd,v $
#   Revision 1.3  2025/04/07 04:01:47  snw
#   Fix output bug in fmd help
#
#   Revision 1.2  2025/04/06 03:38:05  snw
#   Prepare for adding packaging functionality to fmd
#
#   Revision 1.1  2025/04/04 18:00:01  snw
#   *** empty log message ***
#
#
# SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
# SPDX-License-Identifier: AGPL-3.0-or-later
#

PGM=$(basename $0)
SCRIPT_DIR=$(dirname "$0")

source "${SCRIPT_DIR}/_fmd_common.bash"

#echo "Welcome, $(echo ${_fmd_fullname} | awk '{ print $1 }') <${_fmd_email}>!"
#echo
#echo "fmd:  running on ${_fmd_distribution} ${_fmd_osversion} (${_fmd_kernel} kernel) on ${_fmd_arch}"
#echo "fmd:  this repository contains sources for FreeM ${_fmd_freem_version}"

function usage() {
    echo
    echo "FreeM developer utilities"
    echo
    echo "usage:"
    echo
    echo "   ${PGM} <command> [OPTIONS]"
    echo
    echo "   <command> is one of the following:"
    
    for FMDCMD in $(_fmd_commands)
    do
        if [[ "${FMDCMD}" != "pkg" ]]
        then
            echo "      - ${FMDCMD}"
        fi
    done

    echo
    echo " To get detailed help on an individual fmd command:"
    echo "   fmd help <command>"
    echo
    exit 1
}

if [[ $# < 1 ]]
then
    usage
fi

FMD_COMMAND=$1
shift

if [[ "${FMD_COMMAND}" == "help" ]]
then    
    if [[ $# == 0 ]]
    then
        usage
    else
        CMDSCRIPT="${SCRIPT_DIR}/fmd-$1"
        FMD_COMMAND="help"
    fi
else
    CMDSCRIPT="${SCRIPT_DIR}/fmd-${FMD_COMMAND}"    
fi

if [[ ! -x "${CMDSCRIPT}" ]]
then    
    echo "${PGM}:  ${FMD_COMMAND} is not a valid command"
    exit 1
fi    

case "${FMD_COMMAND}" in

    help)
        ${CMDSCRIPT} help
        ;;
    
    log)
        ${SCRIPT_DIR}/fmd-log "${SCRIPT_DIR}/${PGM}" "$1"
        ;;

    commit)
        ${SCRIPT_DIR}/fmd-commit "${SCRIPT_DIR}/${PGM}" "$1"
        ;;
    
    *)
        ${CMDSCRIPT} "${SCRIPT_DIR}/${PGM}" $@
        ;;
    
esac



FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>