Skip to content

Commit

Permalink
feat: Update file templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ypid committed Oct 17, 2021
1 parent b3d851d commit 1d89800
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
24 changes: 24 additions & 0 deletions templates/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# vim: foldmarker={{{,}}}:foldmethod=marker

# SPDX-FileCopyrightText: 2021 Robin Schneider <ypid@riseup.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

SHELL ?= /bin/bash -o nounset -o pipefail -o errexit
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

#-# Help {{{
#-# https://stackoverflow.com/a/26339924/2239985
.PHONY: list
list:
@if command -v mmake >/dev/null 2>&1; then \
mmake help; \
else \
echo "This Makefile has the following targets:"; \
$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) / 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sed 's/^/ /' | sort; \
fi
#-# }}}

test:
@echo "Do something." 1>&2
17 changes: 12 additions & 5 deletions templates/bash_simple_script_template
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
#
# SPDX-License-Identifier: AGPL-3.0-or-later

PS4='+ $(date --rfc-3339=seconds), ${BASH_SOURCE-}:${LINENO-}: '
export PS4
trap 'echo Encountered an unexpected error. Exiting with exit code $? in ${BASH_SOURCE-}:${LINENO-}. >&2' ERR
set -o nounset -o pipefail -o errexit -o errtrace
function main() {
echo "Actual script starts here."
}

echo "Actual script starts here."
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then
PS4='+ $(date --rfc-3339=seconds), ${BASH_SOURCE-}:${LINENO-}: '
export PS4
trap 'echo Encountered an unexpected error. Exiting with exit code $? in ${BASH_SOURCE-}:${LINENO-}. >&2' ERR
set -o nounset -o pipefail -o errexit -o errtrace

main "$@"
fi
31 changes: 31 additions & 0 deletions templates/python3_simple_script_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: 2021 Robin Schneider <ypid@riseup.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

"""
TODO: Use the docstring to give a short description of what the script does.
This is automatically included in the help text. Remove the following reference
to the template itself from the docstring.
"""

import argparse

__version__ = '0.1.0'


def main():
args_parser = argparse.ArgumentParser(description=__doc__)
args_parser.add_argument('-H', '--host', required=True)
args_parser.add_argument(
'-V', '--version', action='version',
version='%(prog)s {}'.format(__version__))
cli_args = args_parser.parse_args()

print(cli_args.host)


if __name__ == '__main__':
main()

0 comments on commit 1d89800

Please sign in to comment.