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.138
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 [ pattern ]
131           Show elements of current node. Can be used with a shell pattern.
132
133       ll [-nz] [-v] [ pattern ... ]
134           Describe elements of current node. Can be used with shell patterns
135           or element names.  Skip empty element with "-nz" option. Display
136           more information with "-v" option
137
138       tree
139           Show configuration tree from current node.
140
141       help
142           Show available commands.
143
144       desc[ription]
145           Show class description of current node.
146
147       desc(elt)
148           Show description of element from current node.
149
150       desc(value)
151           Show effect of value (for enum)
152
153       changes
154           Show unsaved changes
155
156       check
157           Without parameter, show warnings starting from current node. With
158           an element name as parameter, do the same on the element.
159
160       fix Try to fix warning starting from current node. With an element name
161           as parameter, do the same on the element. With ""!"" as parameter,
162           try to fix warnings starting from root node by calling apply_fixes
163           there.
164
165       exit
166           Exit shell
167

CONSTRUCTOR

169   parameters
170       root
171           Root node of the configuration tree
172
173       title
174           UI title
175
176       prompt
177           UI prompt. The prompt will be completed with the location of the
178           current node.
179

Methods

181   run_loop
182       Engage in user interaction until user enters '^D' (CTRL-D).
183

AUTHOR

185       Dominique Dumont, (ddumont at cpan dot org)
186

SEE ALSO

188       Config::Model, Config::Model::Instance, Config::Model::Node,
189

AUTHOR

191       Dominique Dumont
192
194       This software is Copyright (c) 2005-2019 by Dominique Dumont.
195
196       This is free software, licensed under:
197
198         The GNU Lesser General Public License, Version 2.1, February 1999
199
200
201
202perl v5.30.1                      2020-01-29        Config::Model::SimpleUI(3)
Impressum