summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-09-12 23:27:04 +0200
committerAki <please@ignore.pl>2023-09-12 23:27:04 +0200
commit3840c436be9da689086b1d87247da19b17c1da48 (patch)
treefe27b4eae904da935512c26a0fe21972d55ec0d1
parent796162f0d42aa104327c041f910b5922746f6aad (diff)
downloadactivity-3840c436be9da689086b1d87247da19b17c1da48.zip
activity-3840c436be9da689086b1d87247da19b17c1da48.tar.gz
activity-3840c436be9da689086b1d87247da19b17c1da48.tar.bz2
Missing or bad format error should be now more readable
-rw-r--r--generate.lua8
1 files 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
<repos...> (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))