Skip to content

Commit c3d2a1d

Browse files
fix(template-rename): require old name argument
- would be overwritten by correct template updates Signed-off-by: Cameron Smith <cameron.ray.smith@gmail.com>
1 parent 3adf82a commit c3d2a1d

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

nix/modules/template-rename.nix

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,33 @@
3030
RED='\033[0;31m'
3131
NC='\033[0m' # No Color
3232
33-
# Default old names
34-
OLD_NAME="python-nix-template"
35-
OLD_UNDERSCORE="python_nix_template"
36-
3733
# Get the current directory name as default new name
3834
DEFAULT_NEW_NAME=$(basename "$(pwd)")
3935
# Convert to underscore version
4036
DEFAULT_NEW_UNDERSCORE=$(echo "$DEFAULT_NEW_NAME" | tr '-' '_')
4137
42-
# Use command line argument if provided, otherwise use defaults
43-
if [ $# -eq 1 ]; then
44-
NEW_NAME="$1"
38+
# Check for required arguments
39+
if [ $# -lt 1 ]; then
40+
echo -e "''${RED}Error: Missing required argument.''${NC}"
41+
echo "Usage: fix-template-names OLD_NAME [NEW_NAME]"
42+
echo "OLD_NAME: The original template name to be replaced"
43+
echo "NEW_NAME: The new name to use (optional, defaults to current directory name: $DEFAULT_NEW_NAME)"
44+
exit 1
45+
fi
46+
47+
# Set old name from first argument
48+
OLD_NAME="$1"
49+
# Convert to underscore version
50+
OLD_UNDERSCORE=$(echo "$OLD_NAME" | tr '-' '_')
51+
52+
# Use second command line argument if provided, otherwise use defaults
53+
if [ $# -eq 2 ]; then
54+
NEW_NAME="$2"
4555
# Convert to underscore version
4656
NEW_UNDERSCORE=$(echo "$NEW_NAME" | tr '-' '_')
47-
elif [ $# -eq 0 ]; then
57+
else
4858
NEW_NAME="$DEFAULT_NEW_NAME"
4959
NEW_UNDERSCORE="$DEFAULT_NEW_UNDERSCORE"
50-
else
51-
echo -e "''${RED}Error: Too many arguments.''${NC}"
52-
echo "Usage: fix-template-names [new-name]"
53-
echo "If no argument is provided, the current directory name ($DEFAULT_NEW_NAME) will be used."
54-
exit 1
5560
fi
5661
5762
echo -e "''${YELLOW}Starting replacement of template names...''${NC}"

0 commit comments

Comments
 (0)