everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: dtas-all@nongnu.org
Subject: [PATCH] dtas-archive: support -m/--match=REGEXP switch
Date: Mon,  3 Jul 2023 00:43:07 +0000	[thread overview]
Message-ID: <20230703004307.928267-1-e@80x24.org> (raw)

Sometimes I only want to archive files matching a certain regexp pattern.
---
 Documentation/dtas-archive.pod | 11 ++++++++++-
 bin/dtas-archive               |  6 +++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/dtas-archive.pod b/Documentation/dtas-archive.pod
index 157ea70..50237e8 100644
--- a/Documentation/dtas-archive.pod
+++ b/Documentation/dtas-archive.pod
@@ -52,11 +52,20 @@ Continue after error
 
 Number of times to repeat the L<sndfile-cmp(1)> check.  Default: 1
 
+=item -m, --match REGEX
+
+Only archive files matching a given Ruby (or Perl-compatible) regular
+expression.  The regular expression is implementation-dependent and
+using the Perl-compatible subset of Ruby regexps is recommended as dtas
+will be moving away from Ruby at some point.
+
+Added for dtas v0.22.0
+
 =back
 
 =head1 COPYRIGHT
 
-Copyright 2013-2020 all contributors L<mailto:dtas-all@nongnu.org>
+Copyright all contributors L<mailto:dtas-all@nongnu.org>
 
 License: GPL-3.0+ L<https://www.gnu.org/licenses/gpl-3.0.txt>
 
diff --git a/bin/dtas-archive b/bin/dtas-archive
index c88873e..7c0e4f7 100755
--- a/bin/dtas-archive
+++ b/bin/dtas-archive
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2015-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 usage = "#$0 SOURCE DESTINATION"
@@ -30,6 +30,7 @@
 keep_going = false
 compression = []
 comment = []
+match = nil
 
 OptionParser.new('', 24, '  ') do |op|
   op.banner = usage
@@ -47,6 +48,7 @@
   op.on('-r', '--repeat [COUNT]', 'number of times to check', Integer) do |r|
     repeat = r
   end
+  op.on('-m', '--match=REGEX', String) { |s| match = Regexp.new(s) }
   op.on('-s', '--quiet', '--silent') { silent = true }
   op.on('-h', '--help') do
     puts(op.to_s)
@@ -55,6 +57,7 @@
   op.parse!(ARGV)
 end
 
+match ||= %r/./
 comment.push('--comment', '') if comment.empty?
 
 dst = ARGV.pop
@@ -67,6 +70,7 @@
   src_st = File.stat(s)
   if src_st.directory?
     Find.find(s) do |path|
+      path =~ match or next
       File.file?(path) or next
       dir = File.dirname(path)
       dir_st = File.stat(dir)


                 reply	other threads:[~2023-07-03  0:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://80x24.org/dtas/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230703004307.928267-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=dtas-all@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).