1Config::Model::SimpleUIU(s3e)r Contributed Perl DocumentaCtoinofnig::Model::SimpleUI(3)
2
3
4

NAME

6       Config::Model::SimpleUI - Simple interface for Config::Model
7

VERSION

9       version 2.142
10

SYNOPSIS

12        use Config::Model;
13        use Config::Model::SimpleUI ;
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::SimpleUI->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 do:
67
68        $ perl my_test.pl
69        class ui:$ ls
70        foo  bar  hash_of_nodes
71        class ui:$ ll hash_of_nodes
72        name         value        type         comment
73        hash_of_nodes <Foo>        node hash    keys: "en" "fr"
74
75        class ui:$ cd hash_of_nodes:en
76
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
84        class ui: hash_of_nodes:en $  ll
85        name         value        type         comment
86        foo          hello        string
87        bar          bonjour      string
88
89        class ui: hash_of_nodes:en $ ^D
90
91       At the end, the test script dumps the configuration tree. The modified
92       "bar" value can be found in there:
93
94        foo=FOO
95        hash_of_nodes:en
96          foo=hello
97          bar=bonjour -
98        hash_of_nodes:fr
99          foo=bonjour - -
100

DESCRIPTION

102       This module provides a pure ASCII user interface using STDIN and
103       STDOUT.
104

USER COMMAND SYNTAX

106       cd ...
107           Jump into node or value element. You can use "cd <element>", "cd
108           <elt:key>" or "cd -" to go up one node or "cd !"  to go to
109           configuration root.
110
111       set elt=value
112           Set a leaf value.
113
114       set elt:key=value
115           Set a leaf value locate in a hash or list element.
116
117       clear elt
118           Clear leaf value (set to "undef") or removed all elements of hash
119           or list.
120
121       delete elt
122           Delete leaf value.
123
124       delete elt:key
125           Delete a list or hash element
126
127       display node_name elt:key
128           Display a value
129
130       ls [path] [ pattern ]
131           Show elements of current node or of a node pointed by path.
132           Elements can be filtered with a shell pattern. See inline help for
133           more details.
134
135       ll [-nz] [-v] [ pattern ... ]
136           Describe elements of current node. Can be used with shell patterns
137           or element names.  Skip empty element with "-nz" option. Display
138           more information with "-v" option
139
140       tree [path]
141           Show configuration tree from current node or of a node pointed by
142           path.
143
144       info [path]
145           Show debug information on current node or on the element pointed by
146           path. The debug information may show model parametersm default or
147           computed values.
148
149       help
150           Show available commands.
151
152       desc[ription]
153           Show class description of current node.
154
155       desc(elt)
156           Show description of element from current node.
157
158       desc(value)
159           Show effect of value (for enum)
160
161       changes
162           Show unsaved changes
163
164       check
165           Without parameter, show warnings starting from current node. With
166           an element name as parameter, do the same on the element.
167
168       fix Try to fix warning starting from current node. With an element name
169           as parameter, do the same on the element. With ""!"" as parameter,
170           try to fix warnings starting from root node by calling apply_fixes
171           there.
172
173       exit
174           Exit shell
175

CONSTRUCTOR

177   parameters
178       root
179           Root node of the configuration tree
180
181       title
182           UI title
183
184       prompt
185           UI prompt. The prompt will be completed with the location of the
186           current node.
187

Methods

189   run_loop
190       Engage in user interaction until user enters '^D' (CTRL-D).
191

AUTHOR

193       Dominique Dumont, (ddumont at cpan dot org)
194

SEE ALSO

196       Config::Model, Config::Model::Instance, Config::Model::Node,
197

AUTHOR

199       Dominique Dumont
200
202       This software is Copyright (c) 2005-2021 by Dominique Dumont.
203
204       This is free software, licensed under:
205
206         The GNU Lesser General Public License, Version 2.1, February 1999
207
208
209
210perl v5.34.0                      2021-07-22        Config::Model::SimpleUI(3)
Impressum