From af4267a400340ff14d82c93a0765cc7853d0d511 Mon Sep 17 00:00:00 2001 From: SeeLook <seelook@gmail.com> Date: Sat, 8 Feb 2025 13:26:33 +0100 Subject: [PATCH] Tricky script to add Nootka.Music import --- spare_parts/apply_nootka_music.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spare_parts/apply_nootka_music.sh diff --git a/spare_parts/apply_nootka_music.sh b/spare_parts/apply_nootka_music.sh new file mode 100644 index 00000000..3067e234 --- /dev/null +++ b/spare_parts/apply_nootka_music.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Adds Nootka.Music import statement if any QML file uses given class: +# Tmeter, Tclef, Tinstrument, Ttune and this import is missing + +# Check if an argument is provided +if [ -z "$1" ]; then + echo "Usage: $0 <search_string>" + exit 1 +fi + +SEARCH_STRING="$1" + +# Find files containing the search string but not containing "import Nootka.Music" +files=$(grep -l "$SEARCH_STRING" -R src/*qml | xargs grep -L "import Nootka.Music") + +# Loop through each file and replace the line +for file in $files; do + echo $file + sed -i '/^import QtQuick 2\.12$/c\import QtQuick\nimport Nootka.Music' "$file" +done -- GitLab