fixed sourcing guard
This commit is contained in:
parent
af3784ba24
commit
76d492ccae
24
rtenets
24
rtenets
|
@ -37,6 +37,13 @@ readonly ENDPOINT="https://git.dalembert.upmc.fr/api/v1"
|
|||
# Lab info
|
||||
readonly AFFILIATION="Sorbonne Université, CNRS, Institut Jean Le Rond d'Alembert, F-75005 Paris, France"
|
||||
|
||||
# Files
|
||||
readonly MANDATORY_FILES=("README.md"
|
||||
"AUTHORS"
|
||||
"COPYING"
|
||||
"make_all_figures"
|
||||
"tests/run_all_tests")
|
||||
|
||||
# ----------------- Logging commands -----------------------
|
||||
|
||||
# Print error and exit
|
||||
|
@ -228,7 +235,7 @@ fetch_licence() {
|
|||
|
||||
# Create README
|
||||
create_readme() {
|
||||
local readme="README.md~"
|
||||
local readme="${MANDATORY_FILES[0]}"
|
||||
|
||||
if ! [[ -f "${readme}" ]]; then
|
||||
local project_name="$(cond_enter "project name: " PROJECT_NAME)"
|
||||
|
@ -302,14 +309,9 @@ check-tree() {
|
|||
fi
|
||||
|
||||
# Test file structure
|
||||
mandatory_files=("README.md~"
|
||||
"AUTHORS"
|
||||
"COPYING"
|
||||
"make_all_figures"
|
||||
"tests/run_all_tests")
|
||||
for file in ${mandatory_files[*]}; do
|
||||
for file in "${MANDATORY_FILES[@]}"; do
|
||||
if ! [[ -f "${file}" ]]; then
|
||||
warning "file ${file} is missig"
|
||||
warning "file ${file} is missing"
|
||||
check_failed=1
|
||||
fi
|
||||
done
|
||||
|
@ -425,7 +427,7 @@ usage: $0 [--help,-h] [--version,-v] command [args...]
|
|||
|
||||
Available commands:
|
||||
- create: create and populate a repository
|
||||
- init-tree: populate a repository with README, AUTHORS, COPYING and test/
|
||||
- init-tree: populate a repository with README.md, AUTHORS, COPYING and test/
|
||||
- init-gitea: setup a remote on a gitea server with SoftwareHeritage hook
|
||||
- init-workflow: setup a Python virtual environment and Snakemake template
|
||||
- check: verify tenent compliance for a repository
|
||||
|
@ -478,9 +480,9 @@ main() {
|
|||
[check-tree]=check-tree
|
||||
)
|
||||
|
||||
"${COMMANDS[${command:-default}]:-${COMMANDS[default]}}" "${other_args}"
|
||||
"${COMMANDS[${command:-default}]:-${COMMANDS[default]}}" "${other_args[@]:1}"
|
||||
}
|
||||
|
||||
# Avoid executing main if sourced
|
||||
# https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
|
||||
(return 0 2&>/dev/null) && main "$@" || true
|
||||
( return 0 2>/dev/null ) && true || main "$@"
|
||||
|
|
Loading…
Reference in New Issue