-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli,daemon): Support dot-delimited petname paths in eval
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. 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 `eval` formula expects its values to be mediated by formula identifiers, the lookup of `INFO.ten.source` must itself be stored as a formula.
- Loading branch information
Showing
7 changed files
with
124 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Splits a dot-delimited pet name path into an array of pet names. | ||
* Throws if any of the path segments are empty. | ||
* | ||
* @param {string} petNamePath - A dot-delimited pet name path. | ||
* @returns {string[]} - The pet name path, as an array of pet names. | ||
*/ | ||
export const parsePetNamePath = petNamePath => { | ||
const petNames = petNamePath.split('.'); | ||
for (const petName of petNames) { | ||
if (petName === '') { | ||
throw new Error( | ||
`Pet name path "${petNamePath}" contains an empty segment.`, | ||
); | ||
} | ||
} | ||
return petNames; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters