/[cvs]/nfo/perl/libs/OEF/bin/cli.pl
ViewVC logotype

Contents of /nfo/perl/libs/OEF/bin/cli.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Mar 27 15:32:21 2003 UTC (21 years, 1 month ago) by joko
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
initial commit, moved here from elsewhere

1 #!/usr/bin/perl
2
3 ## --------------------------------------------------------------------------------
4 ## $Id: cli.pl,v 1.3 2003/02/21 07:04:41 joko Exp $
5 ## --------------------------------------------------------------------------------
6 ## $Log: cli.pl,v $
7 ## Revision 1.3 2003/02/21 07:04:41 joko
8 ## new startup module
9 ##
10 ## Revision 1.2 2002/12/13 21:52:05 cvsjoko
11 ## + plugin-architecture
12 ##
13 ## Revision 1.1 2002/12/11 07:16:35 cvsjoko
14 ## + initial check-in
15 ##
16 ## --------------------------------------------------------------------------------
17
18
19 use strict;
20 use warnings;
21
22 # dependency startup
23 BEGIN {
24 use FindBin;
25 use lib "$FindBin::RealBin";
26 require 'preface.pl';
27 }
28
29
30 use Data::Dumper;
31 use Data::Walker;
32
33
34 $bizProcess->load('Core');
35
36 # get logger instance
37 my $logger = Log::Dispatch::Config->instance;
38
39
40 sub _read_val {
41 my $val = <STDIN>;
42 exit if !$val;
43 chomp($val);
44 return $val;
45 }
46
47
48 sub _boot_start_cli {
49
50 MENU:
51
52 my $menu = <<MENUTEXT;
53
54 ================
55 Load object(s) ....
56
57 [1] ... directly via id
58 [2] ... by browsing classes
59 [3] ... by building one or more filter(s)
60 [e] exit
61
62 MENUTEXT
63
64 print $menu;
65
66 print "Your selection? ";
67 my $selection = _read_val();
68 print "\n";
69 chomp($selection);
70
71 my $filter;
72 my $result = "Selecting an object seems to have failed.";
73
74 if ($selection eq '1') {
75 print "Please specify object-id: ";
76 my $objectId = _read_val();
77 my $object = $bizProcess->{storage}->getObject($objectId);
78 my $class_meta = $bizProcess->_getClassInfo($object);
79 $result = $object;
80
81 } elsif ($selection eq '2') {
82 my $class = _select_class();
83 $filter = {
84 type => $class,
85 value => 'all',
86 };
87 $result = $bizProcess->getObjectsByFilter($filter);
88
89 } elsif ($selection eq '3') {
90 print "not yet implemented", "\n";
91
92 } elsif ($selection =~ m/^e/) {
93 print "exit!", "\n";
94 exit;
95 }
96
97 my $obj_filter = {
98 type => 'Bet',
99 #field => '',
100 value => 'all',
101 };
102 #$obj_filter{type} = shift;
103 #$obj_filter{field} = shift;
104 #$obj_filter{value} = shift;
105
106 #my $results = $bizProcess->getObjectsByFilter($obj_filter);
107 #my @results = @{$results};
108
109 print "-" x 78, "\n";
110 Data::Walker->cli( $result );
111
112 print "\n";
113
114 goto MENU;
115
116 }
117
118 sub _select_class {
119 my @object_names = Class::Tangram::known_classes();
120 my $counter = 1;
121 foreach (@object_names) {
122 print "[$counter] $_", "\n";
123 $counter++;
124 }
125 print "Please select class: ";
126 my $sel = _read_val();
127 my $idx = $sel - 1;
128 return $object_names[$idx];
129 }
130
131 _boot_start_cli();
132
133 1;
134 __END__

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed