Added Ldoc comments for interactions and orgs.process.lua
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
-- INTERACTIONS.LUA (CLI)
|
||||
|
||||
--- INTERACTIONS.LUA (CLI).
|
||||
-- User interaction functions for Modular Politics
|
||||
-- Called by modpol.lua
|
||||
-- @module modpol.interactions
|
||||
|
||||
modpol.interactions = {}
|
||||
|
||||
@ -9,10 +9,11 @@ modpol.interactions = {}
|
||||
-- DASHBOARDS
|
||||
-- ==========
|
||||
|
||||
-- Function: modpol.interactions.dashboard(user)
|
||||
-- Params: user (string)
|
||||
--- Output: Display a menu of commands to the user
|
||||
-- @function modpol.interactions.dashboard
|
||||
-- @param user (string)
|
||||
|
||||
-- Q: Should this return a menu of commands relevant to the specific user?
|
||||
-- Output: Displays a menu of commands to the user
|
||||
-- TKTK currently just prints all of modpol---needs major improvement
|
||||
function modpol.interactions.dashboard(user)
|
||||
-- adds user to root org if not already in it
|
||||
@ -59,10 +60,10 @@ function modpol.interactions.dashboard(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Function: modpol.interactions.org_dashboard
|
||||
-- Params: user (string), org_string (string or id)
|
||||
-- Output: Displays a menu of org-specific commands to the user
|
||||
--- Output: Displays a menu of org-specific commands to the user
|
||||
-- @function modpol.interactions.org_dashboard
|
||||
-- @param user (string)
|
||||
-- @param org_string (string or id)
|
||||
function modpol.interactions.org_dashboard(user, org_string)
|
||||
local org = modpol.orgs.get_org(org_string)
|
||||
if not org then return nil end
|
||||
@ -169,28 +170,35 @@ end
|
||||
-- output: opens a dashboard for viewing/editing policy details
|
||||
-- TODO
|
||||
|
||||
|
||||
-- Function: modpol.interactions.message
|
||||
-- input: user (string), message (string)
|
||||
-- output: prints message to CLI
|
||||
--- Output: Prints message to CLI
|
||||
-- @function modpol.interactions.message
|
||||
-- @param user (string)
|
||||
-- @param message (string)
|
||||
function modpol.interactions.message(user, message)
|
||||
print(user .. ": " .. message)
|
||||
end
|
||||
|
||||
-- Function: modpol.interactions.text_query
|
||||
-- input: User (string), Query (string), func (function)
|
||||
-- func input: user input (string)
|
||||
-- output: Applies "func" to user input
|
||||
--- Output: Applies "func" to user input.
|
||||
-- Func input: user input (string)
|
||||
-- @function modpol.interactions.text_query
|
||||
-- @param user (string)
|
||||
-- @param query (string)
|
||||
-- @param func (function)
|
||||
function modpol.interactions.text_query(user, query, func)
|
||||
print(user .. ": " .. query)
|
||||
answer = io.read()
|
||||
func(answer)
|
||||
end
|
||||
|
||||
-- Function: dropdown_query
|
||||
-- input: user (string), label (string), options (table of strings), func(choice) (function)
|
||||
-- func input: choice (string)
|
||||
-- output: calls func on choice
|
||||
--- Output: Calls func on choice.
|
||||
-- func input: choice (string)
|
||||
-- @function modpol.interactions.dropdown_query
|
||||
-- @param user (string)
|
||||
-- @param label (string)
|
||||
-- @param options (table of strings)
|
||||
-- @param func (choice) (function)
|
||||
|
||||
|
||||
function modpol.interactions.dropdown_query(user, label, options, func)
|
||||
-- set up options
|
||||
local options_display = ""
|
||||
@ -226,10 +234,12 @@ function modpol.interactions.dropdown_query(user, label, options, func)
|
||||
end
|
||||
end
|
||||
|
||||
-- Function: modpol.binary_poll_user(user, question)
|
||||
-- Params: user (string), question (string), func (function)
|
||||
-- func input: user input (string: y/n)
|
||||
-- Output: Applies "func" to user input
|
||||
--- Output: Applies "func" to user input.
|
||||
-- Func input: user input (string: y/n)
|
||||
-- @function modpol.binary_poll_user(user, question)
|
||||
-- @param user (string)
|
||||
-- @param question (string)
|
||||
-- @param func (function)
|
||||
function modpol.interactions.binary_poll_user(user, question, func)
|
||||
local query = "Poll for " .. user .. " (y/n): ".. question
|
||||
local answer
|
||||
@ -251,9 +261,12 @@ end
|
||||
-- COMPLEX INTERACTIONS
|
||||
-- ====================
|
||||
|
||||
-- Function: modpol.interactions.message_org
|
||||
-- input: initiator (string), org (number or string), message (string)
|
||||
-- output: broadcasts message to all org members
|
||||
--- Output: broadcasts message to all org members
|
||||
-- @function modpol.interactions.message_org
|
||||
-- @param initiator (string)
|
||||
-- @param org (number or string)
|
||||
-- @param message (string)
|
||||
|
||||
function modpol.interactions.message_org(initiator, org, message)
|
||||
local this_org = modpol.orgs.get_org(org)
|
||||
local users = this_org:list_members()
|
||||
|
Reference in New Issue
Block a user