aboutsummaryrefslogtreecommitdiffstats
path: root/emacs/.emacs.d/scripts/find-php-class
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/scripts/find-php-class')
-rwxr-xr-xemacs/.emacs.d/scripts/find-php-class48
1 files changed, 48 insertions, 0 deletions
diff --git a/emacs/.emacs.d/scripts/find-php-class b/emacs/.emacs.d/scripts/find-php-class
new file mode 100755
index 0000000..4268dcf
--- /dev/null
+++ b/emacs/.emacs.d/scripts/find-php-class
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# ;; #!/usr/bin/env -S scsh -e main -o srfi-1 -s
+# ;; !#
+
+# ;; (define (main args)
+# ;; (let* ((class-name (cadr args))
+# ;; (file-names
+# ;; (run/strings (find "."
+# ;; -path "./cdk.out" -prune -o
+# ;; -type f
+# ;; -name ,(string-append class-name ".php")
+# ;; -exec grep "^namespace" "{}" ";")
+# ;; (> 2 "/dev/null"))))
+# ;; (format #t "~s"
+# ;; (delete-duplicates
+# ;; (map (lambda (n)
+# ;; (string-append
+# ;; (match:substring
+# ;; (regexp-search (rx "namespace " (submatch (+ any)) ";") n)
+# ;; 1)
+# ;; "\\"
+# ;; class-name))
+# ;; file-names)))))
+
+main() {
+ local classname=$1
+
+ find . \( \
+ -path "./cdk.out" \
+ -o -path "./punt/tmp" \
+ -o -path "./punt/vendor" \
+ -o -path "./filament/storage/larastan/cache" \
+ -o -path "./filament/vendor" \
+ -o -path "./chanced/tmp" \
+ -o -path "./chanced/node_modules" \
+ -o -path "./chanced/.phpunit.cache" \
+ -o -path "./.git" \
+ -o -path "./chanced/storage" \
+ \) -prune \
+ -o -type f -name "${classname}.php" \
+ -exec grep '^namespace' '{}' \; \
+ | awk "{ print substr(\$0, 11, length(\$0) - 11) \"\\\\${classname}\" }"
+ # for f in "$(git ls-files | grep "${classname}.php")"; do
+ # grep '^namespace' "$f" | awk '{ print substr($0, 11, length($0) - 11) }'
+ # done
+}
+
+main "$@"