Did you know ... | Search Documentation: |
Pack execution_context -- prolog/execution_cli.pl |
current_prolog_flag(argv, Arguments), execute_cli(Arguments)
current_prolog_flag(argv, Arguments)
call
and calls goal registered by cli_command/2 directive. The name of the command is determined
by the first positional argument. Options are removed from the Arguments list by checking against
registered context variables - see context_variable/3 predicate.
Throws cli_option(Type, OptionName)
exception if required arguments are not provided
(see register_cli_command/3), or when the option that cannot be associated with any context variable
is found on command line arguments. The exception can be used for print_message call.
call(Goal, PositionalArguments, Options)
where PositionalArguments are all arguments that are not an command line option, and Options
maps some of the context variables to the goal options.
ArgumentSpec can contain some of the following terms:
describe(Message)
- provides human readable information about the command that is printed when
the CLI command help
or `command help` is invoked.context(ContextVariable, OptionName)
- if call to context_variable_value(ContextVariable, Value)
succeeds, then Goal second argument will contain option named OptionName with the value Value.
If the context_variable is not resolved then the exception is raised and user informed that the required
option is missingoptional(context(ContextVariable, OptionName))
- similar to above, but the c ontext variable is not
required to be resolvedpositional(Nth1, OptionName, Describe)
- associates Nth1 element of positional arguments with option OptionName
when calling Goal. If there are not enough positional argumentsthen the exception is raised and user is
informed that argument is missingoptional(positional(Nth1, OptionName, Describe))
- similar to above, but the positional argument is not
required to be resolved