|
30 | 30 | RED='\033[0;31m' |
31 | 31 | NC='\033[0m' # No Color |
32 | 32 |
|
33 | | - # Default old names |
34 | | - OLD_NAME="python-nix-template" |
35 | | - OLD_UNDERSCORE="python_nix_template" |
36 | | -
|
37 | 33 | # Get the current directory name as default new name |
38 | 34 | DEFAULT_NEW_NAME=$(basename "$(pwd)") |
39 | 35 | # Convert to underscore version |
40 | 36 | DEFAULT_NEW_UNDERSCORE=$(echo "$DEFAULT_NEW_NAME" | tr '-' '_') |
41 | 37 |
|
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" |
45 | 55 | # Convert to underscore version |
46 | 56 | NEW_UNDERSCORE=$(echo "$NEW_NAME" | tr '-' '_') |
47 | | - elif [ $# -eq 0 ]; then |
| 57 | + else |
48 | 58 | NEW_NAME="$DEFAULT_NEW_NAME" |
49 | 59 | 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 |
55 | 60 | fi |
56 | 61 |
|
57 | 62 | echo -e "''${YELLOW}Starting replacement of template names...''${NC}" |
|
0 commit comments