Closed yolken-airplane closed 2 years ago
Are you using v5.3? This is the last release and I'm not able to reproduce the issue.
Thanks for the quick reply. Yes, I'm using v5.3
on a M1 Mac. Here's a printout of my various versions:
$ pg_format --version
pg_format version 5.3
$ perl --version
This is perl 5, version 30, subversion 3 (v5.30.3) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2020, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
And here's a quick way to reproduce (on my system, at least):
$ mkdir sql
$ echo 'select * from my_table' >> sql/test1.sql
$ echo 'select * from my_table' >> sql/test2.sql
$ pg_format -i sql/*.sql
Error: can not use -i | --inplace with an output file (-o | --output) .
...
I also tested in an Ubuntu Docker container and got the same error.
In each case, it does seem to format the first file in-place correctly, but it throws that error when processing the second one. If the glob only expands out to a single file, then it's also ok.
You can not use multiple file as input, here how to achieve what you want to do:
ls sql/*.sql | xargs -i perl pg_format -i {}
but I agree that the error message is not clear, I will fix that.
Commit 73247ab adds the possibility to format inplace multiple files. You can now use pg_format -i sql/*.sql
With the latest release, we're having trouble using the
-i
flag with glob inputs:This worked fine in the previous version. Is there any workaround for this? I've tried setting
-o
to an empty string and a few other things (e.g.,-
) without luck. Thanks!