-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli,daemon): Support dot-delimited petname paths for CLI eval
command
#2034
Conversation
716a073
to
42cdabc
Compare
Adds support for dot-delimited petname paths to the CLI `eval` command. This required modifications to the `evaluate` method of the daemon's `host.js`, and the introduction of a new formula type, `lookup`, modeled on the `web-bundle` formula. Also adds a unit test for this behavior. The `lookup` formula type is necessary because the names in a lookup path may have neither petnames nor formula identifiers associated with them. Consider: ```text > endo eval '10' --name ten 10 > endo eval 'foo' foo:INFO.ten.source 10 ``` The only way retrieve the value for `source` is to call `E(HOST).lookup('INFO', 'ten', 'source')`, and since the `eval` formula expects its values to be mediated by formula identifiers, the lookup of `INFO.ten.source` must itself be stored as a formula.
42cdabc
to
d35bbe2
Compare
1abcb4f
to
f0aefd8
Compare
const petNamePath = petNamePathFrom(petNameOrPath); | ||
if (petNamePath.length === 1) { | ||
const formulaIdentifier = lookupFormulaIdentifierForName( | ||
petNamePath[0], | ||
); | ||
if (formulaIdentifier === undefined) { | ||
throw new Error(`Unknown pet name ${q(petNamePath[0])}`); | ||
} | ||
return formulaIdentifier; | ||
} | ||
return formulaIdentifier; | ||
|
||
const { formulaIdentifier: lookupFormulaIdentifier } = | ||
await provideLookupFormula(petNamePath); | ||
return lookupFormulaIdentifier; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to factor out a lookupFormulaIdentifierForPath
function. This won’t be the last place we use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will do this later if necessary. Leaving this unresolved as a breadcrumb.
Lookup formulas must be associated with the namespace for which the pet name path is valid. In practice, this means an object with a variadic `lookup()` method. Previously, these objects were referred to as "agents", but in the future, not all such object will be agents (i.e. guests or hosts). Therefore, here we replace all references to "agent" with "hub", short for "naming hub".
f0aefd8
to
e6f36a1
Compare
eval
CLI command
eval
CLI commandeval
command
Ref: #2023
Description
Adds support for dot-delimited petname paths to the CLI
eval
command. This required modifications to theevaluate
method of the daemon'shost.js
, and the introduction of a new formula type,lookup
.The
lookup
formula type is necessary because the names in a lookup path may have neither petnames nor formula identifiers associated with them. Consider:The only way retrieve the value for
source
is to callE(HOST).lookup('INFO', 'ten', 'source')
, and since theeval
formula expects its values to be mediated by formula identifiers, the lookup ofINFO.ten.source
must itself be stored as a formula.The
lookup
formula is an-id512
formula with the following interface:The
lookup
formula introduces the language of "naming hubs" into the daemon codebase. At present the only such objects are guests and hosts, which are also agents, but the category of naming hubs is expected to grow to include non-agent objects.