From ac7beb27febab26e3a5f3d1cae070336f27e9e57 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 30 Dec 2024 09:06:26 -0800 Subject: oni-php: Add command to add use statement --- oni-php/scripts/find-php-class | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 oni-php/scripts/find-php-class (limited to 'oni-php/scripts') diff --git a/oni-php/scripts/find-php-class b/oni-php/scripts/find-php-class new file mode 100755 index 0000000..65f43fc --- /dev/null +++ b/oni-php/scripts/find-php-class @@ -0,0 +1,19 @@ +#!/usr/bin/env -S scsh -e main -o srfi-1 -s +!# + +(define (main args) + (let* ((class-name (cadr args)) + (file-names + (run/strings (find "." -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))))) -- cgit v1.3-2-g0d8e