mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-27 19:32:29 +00:00
It's time for mjolnir-shell, a presentation style interface.
While this isn't a true presentation style interface, the idea is that there is an argument stream to commands that we pattern match commands against, and there are different mediums that the commands can be invoked from. There are translators between presentation types and also between commands and mediums to do things like render the result of the command for Matrix etc. This is all inspired by the Common Lisp Interface Manager (CLIM). But there are significant differences since, hello, this is essentially being made for Matrix bots and appservices. This commit is NOT contributed under the Apache-2.0 License. Copyright (C) 2022 Gnuxie <Gnuxie@protonmail.com> All rights reserved.
This commit is contained in:
1 parent
4b254e59f8
commit
d7adaef0bf
10 files changed
+334
-68
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { readCommand, ReadItem } from "../../src/commands/interface-manager/CommandReader";
|
||||
import { paramaters } from "../../src/commands/interface-manager/ParamaterParsing";
|
||||
import { ValidationError, ValidationResult } from "../../src/commands/interface-manager/Validation";
|
||||
import expect from "expect";
|
||||
|
||||
describe('The argument parser goddamn works', function() {
|
||||
it('can parse a simple argument list', function() {
|
||||
const paramaterDescription = paramaters([
|
||||
(item: ReadItem) => {
|
||||
if (typeof item === 'string') {
|
||||
return ValidationResult.Ok(true)
|
||||
} else {
|
||||
return ValidationError.Result('invalid', 'was expecting a string here m8');
|
||||
}
|
||||
}
|
||||
]);
|
||||
expect(paramaterDescription(...readCommand("hello")).ok).toBe(true);
|
||||
// hmm what about providing too many arguments when there's no rest?
|
||||
// how to conveniently test all the edge cases?
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user