-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage_cli.lua
More file actions
60 lines (52 loc) · 1.92 KB
/
usage_cli.lua
File metadata and controls
60 lines (52 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env lua
-- usage_cli.lua - Command-line interface for testing usage command
-- Simulates the /usage command functionality outside of the chat interface
-- Add the current directory to the path so we can require codingbuddy modules
package.path = package.path .. ';./codingbuddy/?.lua'
local usage_analyzer = require('usage_analyzer')
local function show_help()
print("CodingBuddy Usage CLI")
print("====================")
print("")
print("Usage: lua usage_cli.lua [command] [hours]")
print("")
print("Commands:")
print(" all Show all-time usage statistics (default)")
print(" session <N> Show usage statistics for last N hours")
print(" help Show this help message")
print("")
print("Examples:")
print(" lua usage_cli.lua # Show all-time usage")
print(" lua usage_cli.lua session 24 # Show last 24 hours")
print(" lua usage_cli.lua session 1 # Show last 1 hour")
print(" lua usage_cli.lua all # Show all-time usage")
end
local function main(args)
local command = args[1] or "all"
if command == "help" or command == "-h" or command == "--help" then
show_help()
return
end
if command == "all" then
print("Fetching all-time usage statistics...")
print("")
local summary = usage_analyzer.get_total_summary()
print(summary)
elseif command == "session" then
local hours = tonumber(args[2])
if not hours then
print("Error: Please specify number of hours for session command")
print("Example: lua usage_cli.lua session 24")
return
end
print(string.format("Fetching usage statistics for last %d hours...", hours))
print("")
local summary = usage_analyzer.get_session_summary(hours)
print(summary)
else
print("Error: Unknown command '" .. command .. "'")
print("Use 'lua usage_cli.lua help' for usage information")
end
end
-- Execute with command line arguments
main(arg or {})