fpm
fpm copied to clipboard
Ability to customize `fpm new` template
Description
I'd like the ability to customize the template used by the fpm new command for generating projects.
Background: I'm developing my fortran applications using Docker on Windows, using DevContainers. I'd like the ability to generate the dockerfiles and devcontainer.json files automatically.
Possible Solution
No response
Additional Information
No response
I wonder if having a namelist point to a custom directory would do the trick.
Is there a specific reason why this needs to be part of fpm? Couldn't you just put your customizations in a script?
For instance fpm_new_custom.sh (generated by ChatGPT):
#!/usr/bin/env bash
# Forward arguments to `fpm new`
fpm new "$@"
# Extract project name from arguments
PROJECT_NAME="$1"
# Ensure project directory exists
if [ -d "$PROJECT_NAME" ]; then
cd "$PROJECT_NAME" || exit 1
# Create Dockerfile
cat > Dockerfile <<EOF
FROM gcc:latest
RUN apt-get update && \
apt-get install -y gfortran && \
rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
COPY . .
RUN fpm build
CMD ["./build/${PROJECT_NAME}"]
EOF
# Create .devcontainer directory and devcontainer.json
mkdir -p .devcontainer
cat > .devcontainer/devcontainer.json <<EOF
{
"name": "$PROJECT_NAME",
"build": {
"dockerfile": "../Dockerfile"
},
"settings": {},
"extensions": ["ms-vscode.cpptools", "ms-vscode.cmake-tools"],
"postCreateCommand": "fpm build"
}
EOF
echo "Added Dockerfile and devcontainer.json to $PROJECT_NAME"
else
echo "Error: Directory $PROJECT_NAME not found. fpm new might have failed."
exit 1
fi