commit - 19119d2fedbe539eb780c3d76bbcd9a8f66703f0
commit + 424407660e3c3ebcbf0e43c8d9efc2b5aaaba835
blob - f5ed6a49ffe3ace1b6b34ba9dd8688bda078c8df
blob + d2e0e1d2e568d1437e67b10d9b9f043de4f819ec
--- mpd/README.md
+++ mpd/README.md
| `mpd_update_queue` | `[--force] [FILE\|-]` | Replace the queue while preserving playback where possible. |
| `mpd_update_library` | `[--no-wait] [--rescan] [FILE\|-]` | Update unique top-level directories, or the whole database with terminal stdin. |
| `mpd_report` | `[OPTIONS]` | Find database entries by `Last-Modified` time window. |
-| `mpd_report_monthly` | `MONTH [YEAR] [MPD_REPORT_OPTION ...]` | Write the first four weekly reports for a month. |
-| `mpd_report_daily` | `MONTH [YEAR] [MPD_REPORT_OPTION ...]` | Write daily reports for each day of a month. |
+| `mpd_report_monthly` | `[MONTH [YEAR]] [MPD_REPORT_OPTION ...]` | Write the first four weekly reports for a month. |
+| `mpd_report_daily` | `[MONTH [YEAR]] [MPD_REPORT_OPTION ...]` | Write daily reports for each day of a month. |
Queue editing detects concurrent changes and attempts to restore the previous
queue after a replacement failure. Playlist edits stage non-empty replacements
atomically writes all song URIs during the same scan.
`mpd_report_monthly` is a Ruby helper for the four weekly reports created by
-`diggah -m MM -w`. Run `mpd_report_monthly 07 2026` to write
+`diggah -m MM -w`. Run `mpd_report_monthly` (or `mpd_report_monthly 07 2026`) to write
`1_07_2026.txt` through `4_07_2026.txt`; append `--files`, `--path URI`, or
-other `mpd_report` options after `--`. It uses the current year when omitted,
+other `mpd_report` options after `--`. It uses the current month and year when omitted.
accepts `-o DIRECTORY`, and replaces reports atomically after a successful MPD
query.
-`mpd_report_daily` is a Ruby helper for daily reports. Run `mpd_report_daily 07 2026` to
+`mpd_report_daily` is a Ruby helper for daily reports. Run `mpd_report_daily` (or `mpd_report_daily 07 2026`) to
write `01_07_2026.txt` through `31_07_2026.txt`; append `--files`, `--path URI`, or
-other `mpd_report` options after `--`. It uses the current year when omitted,
+other `mpd_report` options after `--`. It uses the current month and year when omitted.
accepts `-o DIRECTORY`, and replaces reports atomically after a successful MPD
query.
blob - 19f8834f353e462655782920915fb7819a2eea80
blob + 1bba23b504c792ead99fd730c2421ce14d8d30e6
--- mpd/mpd_report_daily
+++ mpd/mpd_report_daily
def main(arguments)
options = {output_directory: "."}
parser = OptionParser.new do |opts|
- opts.banner = "Usage: #{opts.program_name} [-o DIRECTORY] MONTH [YEAR] [-- MPD_OPTION ...]"
+ opts.banner = "Usage: #{opts.program_name} [-o DIRECTORY] [MONTH [YEAR]] [-- MPD_OPTION ...]"
opts.on("-o", "--output-dir DIRECTORY", "write reports beneath DIRECTORY") do |directory|
options[:output_directory] = directory
end
arguments.pop if arguments.last == "--"
parser.parse!(arguments)
- month = Integer(arguments.shift || raise(OptionParser::MissingArgument, "MONTH"), 10)
- year = Integer(arguments.shift || Date.today.year, 10)
+ month = (v = arguments.shift) ? Integer(v, 10) : Date.today.month
+ year = (v = arguments.shift) ? Integer(v, 10) : Date.today.year
raise OptionParser::InvalidArgument, arguments.first unless arguments.empty?
first = Date.new(year, month, 1)
blob - a9903b4ee812b8571c8bcab78ae7b241668f8c7d
blob + bb925729754e564dd00223fde6f55df0d738aad3
--- mpd/mpd_report_monthly
+++ mpd/mpd_report_monthly
def main(arguments)
options = {output_directory: "."}
parser = OptionParser.new do |opts|
- opts.banner = "Usage: #{opts.program_name} [-o DIRECTORY] MONTH [YEAR] [-- MPD_OPTION ...]"
+ opts.banner = "Usage: #{opts.program_name} [-o DIRECTORY] [MONTH [YEAR]] [-- MPD_OPTION ...]"
opts.on("-o", "--output-dir DIRECTORY", "write reports beneath DIRECTORY") do |directory|
options[:output_directory] = directory
end
arguments.pop if arguments.last == "--"
parser.parse!(arguments)
- month = Integer(arguments.shift || raise(OptionParser::MissingArgument, "MONTH"), 10)
- year = Integer(arguments.shift || Date.today.year, 10)
+ month = (v = arguments.shift) ? Integer(v, 10) : Date.today.month
+ year = (v = arguments.shift) ? Integer(v, 10) : Date.today.year
raise OptionParser::InvalidArgument, arguments.first unless arguments.empty?
first = Date.new(year, month, 1)
blob - 2bc960bff7d37193a0722371ba579910112d0bd1
blob + 4d6b06a39463e38f3fe5e2980d9aa26880a52958
--- mpd/tests/test_mpd_report_daily.py
+++ mpd/tests/test_mpd_report_daily.py
self.assertTrue(expected.exists())
self.assertEqual(expected.read_text(), "Today\n")
+ def test_uses_current_month_when_month_omitted(self):
+ from datetime import date
+ current_year = date.today().year
+ current_month = date.today().month
+ with tempfile.TemporaryDirectory() as name:
+ directory = Path(name)
+ fake = self.make_fake(directory, "printf '0\tToday\n'\n")
+ result = self.run_helper(directory, fake)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ expected = directory / f"01_{current_month:02d}_{current_year}.txt"
+ self.assertTrue(expected.exists())
+ self.assertEqual(expected.read_text(), "Today\n")
+
if __name__ == "__main__":
unittest.main()
blob - fe0701bb93972102387db6127125af52bc5011df
blob + c020f00d66cb6be3e5df4ffc3f0c270c750957fa
--- mpd/tests/test_mpd_report_monthly.py
+++ mpd/tests/test_mpd_report_monthly.py
self.assertIn("managed by this helper", result.stderr)
+ def test_uses_current_year_when_year_omitted(self):
+ from datetime import date
+ current_year = date.today().year
+ with tempfile.TemporaryDirectory() as name:
+ directory = Path(name)
+ fake = self.make_fake(directory, "printf '0\tWeek1\n'\n")
+ result = self.run_helper(directory, fake, "01")
+ self.assertEqual(result.returncode, 0, result.stderr)
+ expected = directory / f"1_01_{current_year}.txt"
+ self.assertTrue(expected.exists())
+ self.assertEqual(expected.read_text(), "Week1\n")
+
+ def test_uses_current_month_when_month_omitted(self):
+ from datetime import date
+ current_year = date.today().year
+ current_month = date.today().month
+ with tempfile.TemporaryDirectory() as name:
+ directory = Path(name)
+ fake = self.make_fake(directory, "printf '0\tWeek1\n'\n")
+ result = self.run_helper(directory, fake)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ expected = directory / f"1_{current_month:02d}_{current_year}.txt"
+ self.assertTrue(expected.exists())
+ self.assertEqual(expected.read_text(), "Week1\n")
+
if __name__ == "__main__":
unittest.main()