Skip to content

Commit 43aa4e8

Browse files
committed
Renamed node classes
This scheme makes things less ambiguous.
1 parent 67b4892 commit 43aa4e8

File tree

10 files changed

+99
-100
lines changed

10 files changed

+99
-100
lines changed

command-interface/bash.dylan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ copyright: see accompanying file LICENSE
55
66
/* Add hidden command for bash completion to given root
77
*/
8-
define method root-add-bash-completion (root :: <command-root>)
8+
define method root-add-bash-completion (root :: <root-node>)
99
=> ();
1010
let command = build-command
1111
(root, "bashcomplete",

command-interface/building.dylan

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ synopsis: Utilities for constructing CLI node structures.
33
author: Ingo Albrecht <prom@berlin.ccc.de>
44
copyright: see accompanying file LICENSE
55
6-
define method build-command (root :: <command-root>, name :: <sequence>,
6+
define method build-command (root :: <root-node>, name :: <sequence>,
77
#rest node-keys,
8-
#key node-class :: <class> = <command-command>, #all-keys)
9-
=> (cmd :: <command-symbol>);
8+
#key node-class :: <class> = <command-node>, #all-keys)
9+
=> (cmd :: <symbol-node>);
1010
local
11-
method find-or-make-successor (node :: <command-node>,
11+
method find-or-make-successor (node :: <parse-node>,
1212
symbol :: <symbol>,
1313
node-class :: <class>,
1414
node-keys :: <sequence>)
1515
// find symbol in existing successors
1616
let found = #f;
1717
for (s in node-successors(node), until: found)
18-
if (instance?(s, <command-symbol>) & (node-symbol(s) == symbol))
18+
if (instance?(s, <symbol-node>) & (node-symbol(s) == symbol))
1919
found := s;
2020
end if;
2121
end for;
@@ -35,7 +35,7 @@ define method build-command (root :: <command-root>, name :: <sequence>,
3535
if (i == size(name) - 1)
3636
values(node-class, node-keys);
3737
else
38-
values(<command-symbol>, #[]);
38+
values(<symbol-node>, #[]);
3939
end;
4040
// find or make the node
4141
cur := find-or-make-successor
@@ -45,24 +45,24 @@ define method build-command (root :: <command-root>, name :: <sequence>,
4545
cur;
4646
end method;
4747

48-
define method build-command (root :: <command-root>, name :: <string>,
48+
define method build-command (root :: <root-node>, name :: <string>,
4949
#rest keys, #key, #all-keys)
50-
=> (cmd :: <command-symbol>);
50+
=> (cmd :: <command-node>);
5151
apply(build-command, root, list(name), keys);
5252
end method;
5353

54-
define method build-command (root :: <command-root>, name :: <symbol>,
54+
define method build-command (root :: <root-node>, name :: <symbol>,
5555
#rest keys, #key, #all-keys)
56-
=> (cmd :: <command-symbol>);
56+
=> (cmd :: <command-node>);
5757
apply(build-command, root, list(name), keys);
5858
end method;
5959

6060

61-
define function build-parameter (command :: <command-command>, name :: <symbol>,
61+
define function build-parameter (command :: <command-node>, name :: <symbol>,
6262
#rest keys,
6363
#key syntax :: <symbol> = #"named",
6464
#all-keys)
65-
=> (entry :: <command-node>);
65+
=> (entry :: <parse-node>);
6666
select (syntax)
6767
#"flag" => apply(build-flag-parameter, command, name, keys);
6868
#"named" => apply(build-named-parameter, command, name, keys);
@@ -71,8 +71,9 @@ define function build-parameter (command :: <command-command>, name :: <symbol>,
7171
end;
7272
end;
7373

74-
define function build-flag-parameter (command :: <command-command>, name :: <symbol>,
75-
#rest keys, #key node-class :: <class> = <command-flag>, #all-keys)
74+
define function build-flag-parameter (command :: <command-node>, name :: <symbol>,
75+
#rest keys, #key node-class :: <class> = <flag-node>, #all-keys)
76+
=> (param :: <flag-node>);
7677
let param = apply(make, node-class,
7778
name:, name,
7879
symbol:, name,
@@ -85,9 +86,9 @@ define function build-flag-parameter (command :: <command-command>, name :: <sym
8586
param;
8687
end function;
8788

88-
define function build-simple-parameter (command :: <command-command>, name :: <symbol>,
89-
#rest keys, #key node-class :: <class> = <command-string>, #all-keys)
90-
=> (entry :: <command-node>);
89+
define function build-simple-parameter (command :: <command-node>, name :: <symbol>,
90+
#rest keys, #key node-class :: <class> = <string-parameter-node>, #all-keys)
91+
=> (entry :: <parse-node>);
9192
let param = apply(make, node-class,
9293
name:, name,
9394
kind:, #"simple",
@@ -99,9 +100,9 @@ define function build-simple-parameter (command :: <command-command>, name :: <s
99100
param;
100101
end function;
101102

102-
define method build-named-parameter (command :: <command-command>, names :: <sequence>,
103-
#rest keys, #key node-class :: <class> = <command-string>, #all-keys)
104-
=> (param :: <command-node>, symbols :: <sequence>);
103+
define method build-named-parameter (command :: <command-node>, names :: <sequence>,
104+
#rest keys, #key node-class :: <class> = <string-parameter-node>, #all-keys)
105+
=> (param :: <parameter-node>, symbols :: <sequence>);
105106
let param = apply(make, node-class,
106107
name:, element(names, 0),
107108
kind:, #"named",
@@ -110,7 +111,7 @@ define method build-named-parameter (command :: <command-command>, names :: <seq
110111
keys);
111112
let syms = #();
112113
for (name in names)
113-
let sym = make(<command-symbol>,
114+
let sym = make(<symbol-node>,
114115
symbol: as(<symbol>, name),
115116
repeatable?: node-repeatable?(param),
116117
repeat-marker: param,
@@ -122,8 +123,8 @@ define method build-named-parameter (command :: <command-command>, names :: <seq
122123
values(param, syms);
123124
end method;
124125

125-
define method build-named-parameter (command :: <command-command>, name :: <symbol>,
126+
define method build-named-parameter (command :: <command-node>, name :: <symbol>,
126127
#rest keys, #key, #all-keys)
127-
=> (param :: <command-parameter>, symbols :: <sequence>);
128+
=> (param :: <parameter-node>, symbols :: <sequence>);
128129
apply(build-named-parameter, command, list(name), keys);
129130
end method;

command-interface/command-interface-library.dylan

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ define module command-interface
8080
<command-unknown-error>;
8181

8282
export
83-
<command-node>,
83+
<parse-node>,
8484
// getters and setters
8585
node-hidden?,
8686
node-repeatable?,
@@ -91,16 +91,16 @@ define module command-interface
9191
node-complete,
9292
node-match,
9393
// subclasses
94-
<command-root>,
95-
<command-symbol>,
96-
<command-command>,
97-
<command-wrapper>,
98-
<command-parameter>,
99-
<command-string>,
100-
<command-oneof>,
94+
<root-node>,
95+
<symbol-node>,
96+
<command-node>,
97+
<wrapper-node>,
98+
<parameter-node>,
99+
<string-parameter-node>,
100+
<oneof-node>,
101101
parameter-name,
102102
parameter-required?,
103-
<command-file>;
103+
<file-node>;
104104

105105
export
106106
<tty-command-shell>,

command-interface/completion.dylan

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ copyright: see accompanying file LICENSE
99
*/
1010
define class <command-completion> (<object>)
1111
/* node the completion was performed for */
12-
constant slot completion-node :: <command-node>,
12+
constant slot completion-node :: <parse-node>,
1313
required-init-keyword: node:;
1414
/* token used to hint the completion, if provided */
1515
constant slot completion-token :: false-or(<command-token>) = #f,
@@ -56,7 +56,7 @@ end class;
5656
/**
5757
* Construct a completion result
5858
*/
59-
define function make-completion (node :: <command-node>,
59+
define function make-completion (node :: <parse-node>,
6060
token :: false-or(<command-token>),
6161
#key exhaustive? :: <boolean> = #f,
6262
complete-options :: <sequence> = #(),

command-interface/help.dylan

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ synopsis: Reusable help command.
33
author: Ingo Albrecht <prom@berlin.ccc.de>
44
copyright: see accompanying file LICENSE
55
6-
define method root-add-help (root :: <command-root>)
6+
define method root-add-help (root :: <root-node>)
77
=> ();
88
build-command(root, "help",
9-
node-class: <command-wrapper>,
9+
node-class: <wrapper-node>,
1010
root: root,
1111
handler: help-handler);
1212
end method;
@@ -26,20 +26,18 @@ end method;
2626

2727
define method show-command-help (nodes :: <sequence>, tokens :: <sequence>)
2828
=> ();
29-
let cmd :: false-or(<command-command>) = #f;
29+
let cmd :: false-or(<command-node>) = #f;
3030
let cmd-title :: <list> = #();
3131
let cmd-help :: false-or(<string>) = #f;
3232

3333
for (token in tokens, node in nodes)
34-
if (instance?(node, <command-symbol>))
34+
if (instance?(node, <command-node>))
3535
if (~cmd)
36+
cmd := node;
3637
cmd-title := add(cmd-title, as(<string>, node-symbol(node)));
37-
end if;
38-
end if;
39-
if (instance?(node, <command-command>))
40-
cmd := node;
41-
if (command-help(node))
42-
cmd-help := command-help(node);
38+
if (command-help(node))
39+
cmd-help := command-help(node);
40+
end if;
4341
end if;
4442
end if;
4543
end for;

command-interface/macros.dylan

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ copyright: see accompanying file LICENSE
55
66
define macro command-root-definer
77
{ define command-root ?:name }
8-
=> { define constant ?name = make(<command-root>);
8+
=> { define constant ?name = make(<root-node>);
99
begin
1010
root-add-bash-completion(?name);
1111
root-add-help(?name);
@@ -26,7 +26,7 @@ define macro command-aux-definer
2626
(?definitions) (?bindings) (?implementation) (?keywords) (?parameters)
2727
end }
2828
=> { begin
29-
let %root :: <command-root> = ?root;
29+
let %root :: <root-node> = ?root;
3030
let %symbols :: <list> = #(?symbols);
3131
let %handler = method (%parser :: <command-parser>)
3232
=> ();

command-interface/main.dylan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ synopsis: Convenience main functions.
33
author: Ingo Albrecht <prom@berlin.ccc.de>
44
copyright: see accompanying file LICENSE
55
6-
define function tty-command-shell-main (name :: <string>, arguments :: <vector>, tty :: <tty>, root :: <command-root>)
6+
define function tty-command-shell-main (name :: <string>, arguments :: <vector>, tty :: <tty>, root :: <root-node>)
77
let source = make(<command-vector-source>, strings: arguments);
88
let parser = make(<command-parser>, source: source, initial-node: root);
99

0 commit comments

Comments
 (0)