1Config::Model::TermUI(3U)ser Contributed Perl DocumentatiCoonnfig::Model::TermUI(3)
2
3
4
6 Config::Model::TermUI - Interactive command line interface for cme
7
9 version 2.150
10
12 use Config::Model;
13 use Config::Model::TermUI ;
14
15 # define configuration tree object
16 my $model = Config::Model->new;
17 $model->create_config_class(
18 name => "Foo",
19 element => [
20 [qw/foo bar/] => {
21 type => 'leaf',
22 value_type => 'string'
23 },
24 ]
25 );
26 $model ->create_config_class (
27 name => "MyClass",
28
29 element => [
30
31 [qw/foo bar/] => {
32 type => 'leaf',
33 value_type => 'string'
34 },
35 hash_of_nodes => {
36 type => 'hash', # hash id
37 index_type => 'string',
38 cargo => {
39 type => 'node',
40 config_class_name => 'Foo'
41 },
42 },
43 ],
44 ) ;
45
46 my $inst = $model->instance(root_class_name => 'MyClass' );
47
48 my $root = $inst->config_root ;
49
50 # put data
51 my $steps = 'foo=FOO hash_of_nodes:fr foo=bonjour -
52 hash_of_nodes:en foo=hello ';
53 $root->load( steps => $steps );
54
55 my $ui = Config::Model::TermUI->new(
56 root => $root ,
57 title => 'My class ui',
58 prompt => 'class ui',
59 );
60
61 # engage in user interaction
62 $ui -> run_loop ;
63
64 print $root->dump_tree ;
65
66 Once the synopsis above has been saved in "my_test.pl", you can achieve
67 the same interactions as with "Config::Model::SimpleUI". Except that
68 you can use TAB completion:
69
70 class ui:$ ls
71 foo bar hash_of_nodes
72 class ui:$ ll hash_of_nodes
73 name value type comment
74 hash_of_nodes <Foo> node hash keys: "en" "fr"
75
76 class ui:$ cd hash_of_nodes:en
77 class ui: hash_of_nodes:en $ ll
78 name value type comment
79 foo hello string
80 bar [undef] string
81
82 class ui: hash_of_nodes:en $ set bar=bonjour
83 class ui: hash_of_nodes:en $ ll
84 name value type comment
85 foo hello string
86 bar bonjour string
87
88 class ui: hash_of_nodes:en $ ^D
89
90 At the end, the test script dumps the configuration tree. The modified
91 "bar" value can be found in there:
92
93 foo=FOO
94 hash_of_nodes:en
95 foo=hello
96 bar=bonjour -
97 hash_of_nodes:fr
98 foo=bonjour - -
99
101 This module provides a helper to construct pure ASCII user interface on
102 top of Term::ReadLine. To get better interaction you must install
103 either Term::ReadLine::Gnu or Term::ReadLine::Perl.
104
105 Depending on your installation, either Term::ReadLine::Gnu or
106 Term::ReadLine::Perl is used. See Term::ReadLine to override default
107 choice.
108
110 This module is optional and depends on Term::ReadLine to work. To
111 reduce the dependency list of Config::Model, "Term::ReadLine" is only
112 recommended. cme gracefully degrades to Config::Model::SimpleUI when
113 necessary.
114
116 See "USER COMMAND SYNTAX" in Config::Model::SimpleUI.
117
119 parameters
120 root
121 Root node of the configuration tree
122
123 title
124 UI title
125
126 prompt
127 UI prompt. The prompt will be completed with the location of the
128 current node.
129
131 run_loop
132 Engage in user interaction until user enters '^D' (CTRL-D).
133
135 • Auto-completion is not complete.
136
137 • Auto-completion provides wrong choice when you try to "cd" in a
138 hash where the index contains a white space. I.e. the correct
139 command is "cd foo:"a b"" instead of "cd foo: "a b"" as proposed by
140 auto completion.
141
143 Dominique Dumont, (ddumont at cpan dot org)
144
146 Config::Model, Config::Model::Instance, Config::Model::Node,
147
149 Dominique Dumont
150
152 This software is Copyright (c) 2005-2022 by Dominique Dumont.
153
154 This is free software, licensed under:
155
156 The GNU Lesser General Public License, Version 2.1, February 1999
157
158
159
160perl v5.34.1 2022-05-09 Config::Model::TermUI(3)