From a3d64020176d451893b733346ed50c6b5356b450 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 4 Jul 2023 10:57:04 +0200 Subject: [PATCH] Add optional root argument to find file command --- bin/find_files | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/find_files b/bin/find_files index 79647cf..fd047ea 100755 --- a/bin/find_files +++ b/bin/find_files @@ -1,9 +1,16 @@ #!/usr/bin/env lua +local arrr = require 'arrr' +local params = arrr { + { "Sets the root to search in", "--root", "-r", 'root' }; +}{...} + local buf = {} -for _, argument in ipairs{...} do +local root = params.root or "." + +for _, argument in ipairs(params) do table.insert(buf, "-name '"..argument:gsub("'", [['"'"']]).."'") end -os.execute("find . " .. table.concat(buf, " -or ")) +os.execute("find "..root.." " .. table.concat(buf, " -or "))