From 3840c436be9da689086b1d87247da19b17c1da48 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 12 Sep 2023 23:27:04 +0200 Subject: Missing or bad format error should be now more readable --- generate.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generate.lua b/generate.lua index 02d46a8..8deaa68 100644 --- a/generate.lua +++ b/generate.lua @@ -5,5 +5,9 @@ Generates activity chart (optional string) Paths to repositories with activity ]] local activity = require "activity" -local format = require("activity.formats." .. args.f) -io.write(activity.generate_table(args.y, args.repos, format)) +local ok, maybe_format = pcall(require, "activity.formats." .. args.f) +if not ok then + io.stderr:write(("couldn't find specified format: %q\n"):format(args.f)) + os.exit(1) +end +io.write(activity.generate_table(args.y, args.repos, maybe_format)) -- cgit v1.1