Interactive console now autorequires a couple of built-in modules
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
Related dev. issue(s): https://github.com/tarantool/tarantool/issues/9986
Related doc. issue(s): https://github.com/tarantool/doc/issues/4191
Product: Tarantool
Since: 3.2
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/console/
SME: @ Totktonada
There are built-in modules that are frequently used for administration
or debugging purposes. It is convenient to have them accessible in the
interactive console without extra actions.
They're accessible now without a manual require call if the
console_session_scope_vars compat option is set to new (see also
tarantool/doc#4191).
The list of the autorequired modules is below.
- clock
- compat
- config
- datetime
- decimal
- ffi
- fiber
- fio
- fun
- json
- log
- msgpack
- popen
- uuid
- varbinary
- yaml
See tarantool/tarantool#9986 for motivation behind this feature.
This list forms so called initial environment for an interactive console
session. The default initial environment may be adjusted by an
application, for example, to include application specific administrator
functions.
Two public functions are added for this purpose: console.initial_env()
and console.set_initial_env(env).
Example 1 (keep autorequired modules, but add one more variable):
local console = require('console')
-- Add myapp_info function.
local initial_env = console.initial_env()
initial_env.myapp_info = function()
<...>
end
Example 2 (replace the whole initial environment):
local console = require('console')
-- Add myapp_info function, discard the autorequired modules.
console.set_initial_env({
myapp_info = function()
<...>
end,
})
The console.set_initial_env() call without an argument or with a nil
argument drops the initial environment to its default.
A modification of the initial environment doesn't affect existing
console sessions. It affects console sessions that are created
after the modification.
Please, adjust the console_session_scope_vars compat option
description and extend the built-in console module reference with the
new functions.
Requested by @Totktonada in https://github.com/tarantool/tarantool/commit/8c9965a19ce144b30fe6113a5fa87d6f6d66d61b (https://github.com/tarantool/tarantool/issues/9986, https://github.com/tarantool/tarantool/pull/10014).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked console reference, then locate the console_session_scope_vars compat option description and the built-in console module reference. Update those documentation sections to cover the autorequired modules and console.initial_env() and console.set_initial_env(), including the shown usage behavior; done means both requested references describe the new API accurately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100