Command-Line Arguments
Usage Message
Show a usage status when the command is missing.
usage message
Command-line programs usually show usage text when required arguments are missing.
Usage Message
usage_message.lua
Replay: real traced execution (multi-file project)
local command = ""
local status = "usage"
local message = "usage: tool <command>"
if command ~= "" then
status = "ready"
message = "execute:" .. command
end
print("status=" .. status)
print("message=" .. message)
local command = "run"
local status = "usage"
local message = "usage: tool <command>"
if command ~= "" then
status = "ready"
message = "execute:" .. command
end
print("status=" .. status)
print("message=" .. message)
local command = "test"
local status = "usage"
local message = "usage: tool <command>"
if command ~= "" then
status = "ready"
message = "execute:" .. command
end
print("status=" .. status)
print("message=" .. message)
command ← (empty), status ← usage, message ← usage: tool <command>
1local command→ (empty) = "" --@command="run", "test"2local status→ usage = "usage"3local message→ usage: tool <command> = "usage: tool <command>"4if command ~= "" then5 status = "ready"6 message = "execute:" .. command7end8print("status=" .. statususage)9print("message=" .. messageusage: tool <command>)outputstatus=usage message=usage: tool <command>
command ← run, status ← usage, message ← usage: tool <command>
1local command→ run = "run"2local status→ usage = "usage"3local message→ usage: tool <command> = "usage: tool <command>"4if command ~= "" thenstatus ← ready, message ← execute:run
3local message = "usage: tool <command>"4if commandrun ~= "" then5 status→ ready = "ready"6 message→ execute:run = "execute:" .. commandrun7endprint("status=" .. status)
7end8print("status=" .. statusready)9print("message=" .. messageexecute:run)outputstatus=ready message=execute:run
command ← test, status ← usage, message ← usage: tool <command>
1local command→ test = "test"2local status→ usage = "usage"3local message→ usage: tool <command> = "usage: tool <command>"4if command ~= "" thenstatus ← ready, message ← execute:test
3local message = "usage: tool <command>"4if commandtest ~= "" then5 status→ ready = "ready"6 message→ execute:test = "execute:" .. commandtest7endprint("status=" .. status)
7end8print("status=" .. statusready)9print("message=" .. messageexecute:test)outputstatus=ready message=execute:test