summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-09-12 23:20:35 +0200
committerAki <please@ignore.pl>2023-09-12 23:20:35 +0200
commit796162f0d42aa104327c041f910b5922746f6aad (patch)
tree74fbecdb9eb262515e354f408f9bab0cf7e9b654
parentab1cb08298363d429bc811ba2d3375a3fa647065 (diff)
downloadactivity-796162f0d42aa104327c041f910b5922746f6aad.zip
activity-796162f0d42aa104327c041f910b5922746f6aad.tar.gz
activity-796162f0d42aa104327c041f910b5922746f6aad.tar.bz2
Extended the CLI with more traditional option handling
-rw-r--r--activity/formats/ansi.lua58
-rw-r--r--generate.lua12
2 files changed, 66 insertions, 4 deletions
diff --git a/activity/formats/ansi.lua b/activity/formats/ansi.lua
new file mode 100644
index 0000000..dae5bcb
--- /dev/null
+++ b/activity/formats/ansi.lua
@@ -0,0 +1,58 @@
+local ansi = {}
+
+
+function ansi.start_document (_)
+ return ""
+end
+
+
+function ansi.end_document ()
+ return ""
+end
+
+
+function ansi.start_table ()
+ return ""
+end
+
+
+function ansi.end_table ()
+ return ""
+end
+
+
+function ansi.start_row ()
+ return ""
+end
+
+
+function ansi.end_row ()
+ return "\n"
+end
+
+
+function ansi.label (name)
+ return ("%5s "):format(name)
+end
+
+
+function ansi.spot ()
+ return " "
+end
+
+
+local colours = {
+ [0] = "238",
+ "22",
+ "28",
+ "34",
+ "46",
+}
+
+
+function ansi.cell (level)
+ return ("\27[38;5;%dm"):format(colours[level]) .. "◼" .. "\27[0m"
+end
+
+
+return ansi
diff --git a/generate.lua b/generate.lua
index c9a21bf..02d46a8 100644
--- a/generate.lua
+++ b/generate.lua
@@ -1,5 +1,9 @@
+local args = require "pl.lapp" [[
+Generates activity chart
+ -f (string default 'ansi') Output format of the chart
+ -y (optional number) Year of the chart
+ <repos...> (optional string) Paths to repositories with activity
+]]
local activity = require "activity"
-local format = require "activity.formats.html5"
-local args = {...}
-local year = tonumber(table.remove(args, 1))
-print(activity.generate_table(year, args, format))
+local format = require("activity.formats." .. args.f)
+io.write(activity.generate_table(args.y, args.repos, format))