<div dir="ltr"><div dir="ltr">On Wed, Nov 9, 2022 at 12:09 PM Thomas Monjalon <<a href="mailto:thomas@monjalon.net">thomas@monjalon.net</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The script was running on the current directory.<br>
If not in the DTS directory, it would re-format every Python files.<br>
<br>
A new positional argument is added to specify the directory to check.<br>
In most cases, the (new) default value should be enough.<br>
<br>
While updating argument handling,<br>
the usage is printed in case of wrong argument.<br>
<br>
Signed-off-by: Thomas Monjalon <<a href="mailto:thomas@monjalon.net" target="_blank">thomas@monjalon.net</a>><br>
---<br>
devtools/dts-check-format.sh | 14 ++++++++++----<br>
1 file changed, 10 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/devtools/dts-check-format.sh b/devtools/dts-check-format.sh<br>
index dc07150775..eb1bdd2a01 100755<br>
--- a/devtools/dts-check-format.sh<br>
+++ b/devtools/dts-check-format.sh<br>
@@ -3,11 +3,10 @@<br>
# Copyright(c) 2022 University of New Hampshire<br>
<br>
usage() {<br>
- echo "Run formatting and linting programs for DTS. Usage:"<br>
-<br>
+ echo 'Usage: $(basename $0) [options] [directory]'<br>
+ echo 'Options:'<br>
# Get source code comments after getopts arguments and print them both<br>
grep -E '[a-zA-Z]+\) +#' "$0" | tr -d '#'<br>
- exit 0<br>
}<br>
<br>
format=true<br>
@@ -17,7 +16,9 @@ lint=true<br>
while getopts "hfl" arg; do<br>
case $arg in<br>
h) # Display this message<br>
+ echo 'Run formatting and linting programs for DTS.'<br>
usage<br>
+ exit 0<br>
;;<br>
f) # Don't run formatters<br>
format=false<br>
@@ -25,10 +26,15 @@ while getopts "hfl" arg; do<br>
l) # Don't run linter<br>
lint=false<br>
;;<br>
- *)<br>
+ ?)<br>
+ usage<br>
+ exit 1<br>
esac<br>
done<br>
+shift $(($OPTIND - 1))<br>
<br>
+directory=${1:-$(dirname $0)/../dts}<br>
+cd $directory || exit 1<br>
<br>
errors=0<br>
<br>
-- <br>
2.36.1<br>
<br></blockquote><div><br></div>Looks good to me.<br><br><div>Reviewed-by: Owen Hilyard <<a href="mailto:ohilyard@iol.unh.edu">ohilyard@iol.unh.edu</a>> </div></div></div>