Compare commits
2 commits
eb2f1410c8
...
e5b2b4e016
Author | SHA1 | Date | |
---|---|---|---|
e5b2b4e016 | |||
ea29526f54 |
1 changed files with 10 additions and 9 deletions
19
c4mate
19
c4mate
|
@ -102,7 +102,7 @@ function MatePad:parse_log(size)
|
||||||
-- Then extract and print oldbalance, newbalance, parameter and method.
|
-- Then extract and print oldbalance, newbalance, parameter and method.
|
||||||
-- Depending on method, print either reason or item_name. If any extraction
|
-- Depending on method, print either reason or item_name. If any extraction
|
||||||
-- fails we fail with exit code 1.
|
-- fails we fail with exit code 1.
|
||||||
-- Note: we allow quoted quotation marks in "reason".
|
-- Note: we allow escaped quotation marks in "reason" and "item_name".
|
||||||
pipe = io.popen(string.format([=[
|
pipe = io.popen(string.format([=[
|
||||||
curl %s --header "Accept: application/json" "%s/api/user/%s/log?type=json" | \
|
curl %s --header "Accept: application/json" "%s/api/user/%s/log?type=json" | \
|
||||||
sed -n --sandbox '
|
sed -n --sandbox '
|
||||||
|
@ -135,7 +135,7 @@ sed -n '
|
||||||
b
|
b
|
||||||
}
|
}
|
||||||
g
|
g
|
||||||
s/.*"item_name" *: *\(null\|"\([^"]*\)"\).*/\2/p
|
s/.*"item_name" *: *\(null\|"\(\([^"]\|\\"\)*[^\\]\)"\).*/\2/p
|
||||||
T fail
|
T fail
|
||||||
b
|
b
|
||||||
:fail
|
:fail
|
||||||
|
@ -305,6 +305,14 @@ function MatePad:give(amount, recipient, reason)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Parse -u flag (which may be given multiple times).
|
||||||
|
while arg[1] == "-u" do
|
||||||
|
table.remove(arg, 1)
|
||||||
|
USER = arg[1]
|
||||||
|
table.remove(arg, 1)
|
||||||
|
end
|
||||||
|
|
||||||
-- Process help and username options.
|
-- Process help and username options.
|
||||||
if arg[1] == "-h" or
|
if arg[1] == "-h" or
|
||||||
arg[1] == "--help" then
|
arg[1] == "--help" then
|
||||||
|
@ -326,13 +334,6 @@ Give credits:
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Parse -u flag (which may be given multiple times).
|
|
||||||
while arg[1] == "-u" do
|
|
||||||
table.remove(arg, 1)
|
|
||||||
USER = arg[1]
|
|
||||||
table.remove(arg, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set up username.
|
-- Set up username.
|
||||||
if USER == nil then
|
if USER == nil then
|
||||||
USER = os.getenv("USER")
|
USER = os.getenv("USER")
|
||||||
|
|
Loading…
Add table
Reference in a new issue