| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/bin/bash
- #
- # Combines *.swift files into a single file.
- #
- # Usage
- # ------
- #
- # ./combine_swift_files.sh source_dir destination_file [optional_header_text]
- #
- destination=$2
- headermessage=$3
- if [ "$#" -lt 2 ]
- then
- echo "\nUsage:\n"
- echo " ./combine_swift_files.sh source_dir destination_file [optional_header_text]\n"
- exit 1
- fi
- # Create empty destination file
- echo > "$destination";
- text=""
- destination_filename=$(basename "$destination")
- for swift in `find $1 ! -name "$destination_filename" -name "*.swift"`;
- do
- filename=$(basename "$swift")
- text="$text\n// ----------------------------";
- text="$text\n//";
- text="$text\n// ${filename}";
- text="$text\n//";
- text="$text\n// ----------------------------\n\n";
- text="$text$(cat "${swift}";)\n\n";
- echo "Combining $swift";
- done;
- # Add header message
- if [ -n "$headermessage" ]
- then
- text="$headermessage\n\n$text"
- fi
- # Write to destination file
- echo -e "$text" > "$destination"
- echo -e "\nSwift files combined into $destination"
|