This commit is contained in:
César Jesús Dosé Preciado Calderon 2025-07-11 23:47:40 -05:00 committed by GitHub
commit d3ed8efa35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python3
from __future__ import print_function
@ -323,6 +323,7 @@ if __name__ == "__main__":
parser.add_argument('-l', '--list', action='store_true', help='List files in archive ARCHIVE.')
parser.add_argument('-x', '--extract', action='store_true', help='Extract FILEs from ARCHIVE.')
parser.add_argument('--only', metavar='EXT', help='Optional: extract only files with this extension (e.g., .png)')
parser.add_argument('-c', '--create', action='store_true', help='Creative ARCHIVE from FILEs.')
parser.add_argument('-d', '--delete', action='store_true', help='Delete FILEs from ARCHIVE.')
parser.add_argument('-a', '--append', action='store_true', help='Append FILEs to ARCHIVE.')
@ -433,6 +434,11 @@ if __name__ == "__main__":
files = arguments.files
else:
files = archive.list()
# optional filter --only
if arguments.only:
files = [f for f in files if f.lower().endswith(arguments.only.lower())]
# Create output directory if not present.
if not os.path.exists(output):