John Smith commited on 2021-326 23:26:52
Showing 1 changed files, with 48 additions and 0 deletions.
`main.lua` shall provide a CLI/TUI for memoire; the beginnings of that have been implemented (help text, for now). The change in verb inflection in commit summaries is deliberate; the new form is correct.
| ... | ... |
@@ -0,0 +1,48 @@ |
| 1 |
+--[[ |
|
| 2 |
+ the main user interface for memoire |
|
| 3 |
+]] |
|
| 4 |
+ |
|
| 5 |
+--[[ |
|
| 6 |
+ check action based on first command-line argument; |
|
| 7 |
+ if nothing valid given, default to help |
|
| 8 |
+]] |
|
| 9 |
+local action = nil |
|
| 10 |
+if arg[1] then |
|
| 11 |
+ local fc = arg[1]:sub(1, 1) |
|
| 12 |
+ if fc == "a" or fc == "h" or fc == "r" or fc == "s" then |
|
| 13 |
+ action = fc |
|
| 14 |
+ else |
|
| 15 |
+ action = "h" |
|
| 16 |
+ end |
|
| 17 |
+else |
|
| 18 |
+ action = "h" |
|
| 19 |
+end |
|
| 20 |
+ |
|
| 21 |
+--[[ |
|
| 22 |
+ repository file is hardcoded for now; |
|
| 23 |
+ TODO: should be controllable by user in the future |
|
| 24 |
+]] |
|
| 25 |
+local deckfname = "example.rec" |
|
| 26 |
+ |
|
| 27 |
+--[[ |
|
| 28 |
+ do requested action |
|
| 29 |
+]] |
|
| 30 |
+-- Add card(s) |
|
| 31 |
+if action == "a" then |
|
| 32 |
+ -- TODO |
|
| 33 |
+-- Help |
|
| 34 |
+elseif action == "h" then |
|
| 35 |
+ io.write(string.format( |
|
| 36 |
+ "Usage: %s ACTION\n\nACTION may be one of\n (a)dd card\n (h)elp\n (r)eview session\n (s)tatistics\n", |
|
| 37 |
+ arg[0] |
|
| 38 |
+ )) |
|
| 39 |
+-- Review session |
|
| 40 |
+elseif action == "r" then |
|
| 41 |
+ -- TODO |
|
| 42 |
+-- Statistics |
|
| 43 |
+elseif action == "s" then |
|
| 44 |
+ -- TODO |
|
| 45 |
+else |
|
| 46 |
+ io.write "unreachable" |
|
| 47 |
+end |
|
| 48 |
+ |
|
| 0 | 49 |