Closed amirhossein-ka closed 2 years ago
Hi @amirhossein-ka ,
The options can't be required.
You have some workarounds:
command <input>
. The parsed.input
in the action function will contain the command.Command definition:
lummander
instace (cli
in the example)
cli:command("command <input>", "My command description")
:action(function(parsed, command, app)
print("My command input is" .. parsed.input)
end)
or use some variations mentioned here
Object command definition in file:
return {
command = "command <input>",
description = "My command description",
action = function(parsed, command, lum)
print("My command input is" .. parsed.input)
end
}
-c
as an option and returns a message early if this option is not set in the command action
functionCommand definition:
lummander
instace (cli
in the example) and using its methods
cli:command("command", "My command description")
:option(
"command","c","Command option description",nil,"normal",nil)
:action(function(parsed, command, app)
if (not parsed.command) then return print("The --command/-c flag is required") end
....
end)
or use some variations mentioned here
Object command definition in file if you load commands from files as explained here:
return {
command = "command",
description = "My command description",
options = {
{short = "c", long = "command", description = "Command option description", type = "normal"}
},
action = function(parsed, command, lum)
if (not parsed.command) then return print("The --command/-c flag is required") end
....
end
}
hello i want to get input like this
./myapp command -c <input>
is it possible to make this option required or i need to get it from command ?