From 7318b8d66490fcbc29e185a065dcf129faea75e4 Mon Sep 17 00:00:00 2001 From: Luke Miller Date: Sun, 4 Jul 2021 23:54:54 -0400 Subject: [PATCH] working on upgrading CLI --- modpol/interactions/console.lua | 7 +++++++ modpol/interactions/interactions.lua | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 modpol/interactions/console.lua diff --git a/modpol/interactions/console.lua b/modpol/interactions/console.lua new file mode 100644 index 0000000..ff0db13 --- /dev/null +++ b/modpol/interactions/console.lua @@ -0,0 +1,7 @@ +dofile("../modpol.lua") + +print("Log in as which user?") +local username = io.read() + +local org = modpol.dashboard(username) +modpol.interactions.org_dashboard(username, org) \ No newline at end of file diff --git a/modpol/interactions/interactions.lua b/modpol/interactions/interactions.lua index e6ba855..d660b99 100644 --- a/modpol/interactions/interactions.lua +++ b/modpol/interactions/interactions.lua @@ -15,16 +15,17 @@ modpol.interactions = {} -- Output: Displays a menu of commands to the user -- TKTK currently just prints all of modpol---needs major improvement function modpol.dashboard(user) - local output = "" - -- Org status - output = output .. "Orgs:\n" .. - table.concat(modpol.orgs.list_all(),"\n") - -- Command list (should be redone to be org-specific) - output = output .. "\nCommand list:\n" - for key,value in pairs(modpol) do - output = output .. "modpol." .. key .. " " + print() + local user_orgs = modpol.orgs.user_orgs(user) + + print('Select an org') + for i, org in ipairs(user_orgs) do + print('['..i..']'..' '..org) end - print(output) + + local sel = io.read() + return user_orgs[tonumber(sel)] + end @@ -32,8 +33,10 @@ end -- Params: user (string), org_name (string) -- Output: Displays a menu of org-specific commands to the user function modpol.interactions.org_dashboard(user, org_name) + print() local org = modpol.orgs.get_org(org_name) if not org then return nil end + local is_member = org:has_member(user) local membership_toggle = function() local toggle_code = ""