diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-01-26 18:47:59 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-01-26 18:47:59 +0000 |
commit | 71cbdc86adfa7c32cb7407c8ad822b25fc9a173f (patch) | |
tree | 12cd38cfde3ea8d30e4925139aa440aece8cc216 /util/prosodyctl.lua | |
parent | 19bcbcde9c09abdad8fdeadf3758288e0ff76a12 (diff) | |
parent | 5cf8e1100c7480ebe5aa8164bf501d8519ae40c9 (diff) | |
download | prosody-71cbdc86adfa7c32cb7407c8ad822b25fc9a173f.tar.gz prosody-71cbdc86adfa7c32cb7407c8ad822b25fc9a173f.zip |
Merge with Zash
Diffstat (limited to 'util/prosodyctl.lua')
-rw-r--r-- | util/prosodyctl.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua index d0045abc..8c58f2cd 100644 --- a/util/prosodyctl.lua +++ b/util/prosodyctl.lua @@ -16,6 +16,7 @@ local signal = require "util.signal"; local set = require "util.set"; local lfs = require "lfs"; local pcall = pcall; +local type = type; local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep; @@ -63,6 +64,13 @@ function getchar(n) end end +function getline() + local ok, line = pcall(io.read, "*l"); + if ok then + return line; + end +end + function getpass() local stty_ret = os.execute("stty -echo 2>/dev/null"); if stty_ret ~= 0 then @@ -112,6 +120,13 @@ function read_password() return password; end +function show_prompt(prompt) + io.write(prompt, " "); + local line = getline(); + line = line and line:gsub("\n$",""); + return (line and #line > 0) and line or nil; +end + -- Server control function adduser(params) local user, host, password = nodeprep(params.user), nameprep(params.host), params.password; |