1: #!/usr/bin/env bash
2:
3: #
4: # $Id: fmd,v 1.3 2025/04/07 04:01:47 snw Exp $
5: # FreeM dev script wrapper
6: #
7: #
8: # Author: Serena Willis <snw@coherent-logic.com>
9: # Copyright (C) 2025 Coherent Logic Development LLC
10: #
11: #
12: # This file is part of FreeM.
13: #
14: # FreeM is free software: you can redistribute it and/or modify
15: # it under the terms of the GNU Affero Public License as published by
16: # the Free Software Foundation, either version 3 of the License, or
17: # (at your option) any later version.
18: #
19: # FreeM is distributed in the hope that it will be useful,
20: # but WITHOUT ANY WARRANTY; without even the implied warranty of
21: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22: # GNU Affero Public License for more details.
23: #
24: # You should have received a copy of the GNU Affero Public License
25: # along with FreeM. If not, see <https://www.gnu.org/licenses/>.
26: #
27: # $Log: fmd,v $
28: # Revision 1.3 2025/04/07 04:01:47 snw
29: # Fix output bug in fmd help
30: #
31: # Revision 1.2 2025/04/06 03:38:05 snw
32: # Prepare for adding packaging functionality to fmd
33: #
34: # Revision 1.1 2025/04/04 18:00:01 snw
35: # *** empty log message ***
36: #
37: #
38: # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
39: # SPDX-License-Identifier: AGPL-3.0-or-later
40: #
41:
42: PGM=$(basename $0)
43: SCRIPT_DIR=$(dirname "$0")
44:
45: source "${SCRIPT_DIR}/_fmd_common.bash"
46:
47: #echo "Welcome, $(echo ${_fmd_fullname} | awk '{ print $1 }') <${_fmd_email}>!"
48: #echo
49: #echo "fmd: running on ${_fmd_distribution} ${_fmd_osversion} (${_fmd_kernel} kernel) on ${_fmd_arch}"
50: #echo "fmd: this repository contains sources for FreeM ${_fmd_freem_version}"
51:
52: function usage() {
53: echo
54: echo "FreeM developer utilities"
55: echo
56: echo "usage:"
57: echo
58: echo " ${PGM} <command> [OPTIONS]"
59: echo
60: echo " <command> is one of the following:"
61:
62: for FMDCMD in $(_fmd_commands)
63: do
64: if [[ "${FMDCMD}" != "pkg" ]]
65: then
66: echo " - ${FMDCMD}"
67: fi
68: done
69:
70: echo
71: echo " To get detailed help on an individual fmd command:"
72: echo " fmd help <command>"
73: echo
74: exit 1
75: }
76:
77: if [[ $# < 1 ]]
78: then
79: usage
80: fi
81:
82: FMD_COMMAND=$1
83: shift
84:
85: if [[ "${FMD_COMMAND}" == "help" ]]
86: then
87: if [[ $# == 0 ]]
88: then
89: usage
90: else
91: CMDSCRIPT="${SCRIPT_DIR}/fmd-$1"
92: FMD_COMMAND="help"
93: fi
94: else
95: CMDSCRIPT="${SCRIPT_DIR}/fmd-${FMD_COMMAND}"
96: fi
97:
98: if [[ ! -x "${CMDSCRIPT}" ]]
99: then
100: echo "${PGM}: ${FMD_COMMAND} is not a valid command"
101: exit 1
102: fi
103:
104: case "${FMD_COMMAND}" in
105:
106: help)
107: ${CMDSCRIPT} help
108: ;;
109:
110: log)
111: ${SCRIPT_DIR}/fmd-log "${SCRIPT_DIR}/${PGM}" "$1"
112: ;;
113:
114: commit)
115: ${SCRIPT_DIR}/fmd-commit "${SCRIPT_DIR}/${PGM}" "$1"
116: ;;
117:
118: *)
119: ${CMDSCRIPT} "${SCRIPT_DIR}/${PGM}" $@
120: ;;
121:
122: esac
123:
124:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>