update
This commit is contained in:
@@ -189,6 +189,7 @@ def main(argv=None):
|
||||
p.add_argument('--out', default='results.json', help='Output file')
|
||||
p.add_argument('--format', choices=['json','csv'], default='json')
|
||||
p.add_argument('--copy-to', help='Optional: copy matched markdown files to this dir')
|
||||
p.add_argument("--copy-to-clear", default=True, action="store_true", help="Overwrite files when copying to --copy-to")
|
||||
args = p.parse_args(argv)
|
||||
|
||||
if ':' not in args.query:
|
||||
@@ -204,6 +205,16 @@ def main(argv=None):
|
||||
|
||||
if args.copy_to and results:
|
||||
os.makedirs(args.copy_to, exist_ok=True)
|
||||
if args.copy_to_clear:
|
||||
# clear existing files in target dir
|
||||
for existing_fn in os.listdir(args.copy_to):
|
||||
existing_path = os.path.join(args.copy_to, existing_fn)
|
||||
try:
|
||||
if os.path.isfile(existing_path):
|
||||
os.remove(existing_path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for r in results:
|
||||
try:
|
||||
dst = os.path.join(args.copy_to, os.path.basename(r['path']))
|
||||
|
||||
Reference in New Issue
Block a user