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

command
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)
  1. 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>
  1. 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 ~= "" then
  2. status ← ready, message ← execute:run

    3local message = "usage: tool <command>"4if commandrun ~= "" then5  status→ ready = "ready"6  message→ execute:run = "execute:" .. commandrun7end
  3. print("status=" .. status)

    7end8print("status=" .. statusready)9print("message=" .. messageexecute:run)
    outputstatus=ready
    message=execute:run
  1. 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 ~= "" then
  2. status ← ready, message ← execute:test

    3local message = "usage: tool <command>"4if commandtest ~= "" then5  status→ ready = "ready"6  message→ execute:test = "execute:" .. commandtest7end
  3. print("status=" .. status)

    7end8print("status=" .. statusready)9print("message=" .. messageexecute:test)
    outputstatus=ready
    message=execute:test