-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_showgroups.pl
More file actions
151 lines (115 loc) · 3.58 KB
/
db_showgroups.pl
File metadata and controls
151 lines (115 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/perl
#
use warnings;
use strict;
use LinWin::Schema;
## begin user documentation stuff
use Getopt::Long;
use Pod::Usage;
my $db_showgroups_VER = '0.1';
my $opt_debug = 0;
my ( $opt_help, $opt_man, $opt_versions );
my $gid;
GetOptions(
'debug=i' => \$opt_debug,
'help!' => \$opt_help,
'man!' => \$opt_man,
'versions!' => \$opt_versions,
'gid=s' => \$gid,
) or pod2usage( -verbose => 1 ) && exit;
pod2usage( -verbose => 1 ) && exit if ( $opt_debug !~ /^[10]$/ );
pod2usage( -verbose => 1 ) && exit if defined $opt_help;
pod2usage( -verbose => 2 ) && exit if defined $opt_man;
print
"\nModules, Perl, OS, Program info:\n",
" DBIx::Class $DBIx::Class::VERSION\n",
" Pod::Usage $Pod::Usage::VERSION\n",
" Getopt::Long $Getopt::Long::VERSION\n",
" strict $strict::VERSION\n",
" Perl $]\n",
" OS $^O\n",
" db_showgroups.pl $db_showgroups_VER\n", " $0\n", "\n\n"
&& exit
if defined $opt_versions;
## end user documentation stuff
my $schema = LinWin::Schema->connect('dbi:SQLite:db/example.db');
print @ARGV . "\n" if $opt_debug;
print "Please enter an gid:\n" if !defined $gid;
chomp(my $gid = <STDIN> );
my $groups_rs = $schema->resultset('Group')->search( { GID => $gid } );
foreach my $group_obj ( $groups_rs->next ) {
print "Group: " . $group_obj->GID . ":\n";
print $group_obj->GROUP_NAME;
print $group_obj->GROUP_DESC;
print $group_obj->GID;
print "\n";
my %group = $group_obj->get_columns;
for my $key ( keys %group ) {
print "$key => $group{key}\n";
}
}
#print "His status is: " . $groups_rs->status()->STATUS_NAME . "\n";
#print "The groups are : \n";
#while ( my $group = $groups->next) {
# print $group->GROUP_NAME . ",";
#}
#print "The gecos is $gecos\n";
#
END {
if ( defined $opt_versions ) {
print
"\nModules, Perl, OS, Program info:\n",
" DBIx::Class $DBIx::Class::VERSION\n",
" Pod::Usage $Pod::Usage::VERSION\n",
" Getopt::Long $Getopt::Long::VERSION\n",
" strict $strict::VERSION\n",
" Perl $]\n",
" OS $^O\n",
" db_showgroups.pl $db_showgroups_VER\n",
" $0\n",
"\n\n";
}
}
=head1 NAME
db_showgroups.pl
=head1 SYNOPSIS
db_showgroups.pl ./tcbfile.csv
=head1 DESCRIPTION
Import a file into the new Engdatabase
Default is to import a tcbfile
Ensure that it is just pure csv (remove all double quotation marks)
Perl doesn't need no quotation marks
Switches that don't define a value can be done in long or short form.
eg:
db_showgroups.pl --man
db_showgroups.pl -m
=head1 ARGUMENTS
File
--help print Options and Arguments instead of importing into db
--man print complete man page instead of importing into db
=head1 OPTIONS
--versions print Modules, Perl, OS, Program info
--debug 0 don't print debugging information (default)
--debug 1 print debugging information
=head1 AUTHOR
Gavin Rogers
=head1 CREDITS
=head1 TESTED
DBIx::Class 0.08250
Pod::Usage 1.36
Getopt::Long 2.41
strict 1.04
Perl 5.010001
OS linux
=head1 BUGS
None that I know of.
=head1 TODO
Map some dark magic to proper statuses? Find out what the dark
magic is?
=head1 UPDATES
2013-08-21
Added user documentation
2013-08-19
Initial working code
=cut
## Please see file perltidy.ERR