fixed perl filtering
[scpubgit/System-Introspector.git] / bin / system-introspector
1 #!/usr/bin/env perl
2 use strictures 1;
3
4 use Getopt::Long;
5 use Pod::Usage;
6 use System::Introspector::State;
7 use File::Tree::Snapshot;
8 use System::Introspector::Config;
9
10 GetOptions(
11     'c|config=s'    => \my $config_file,
12     's|storage=s'   => \my $storage_dir,
13     'a|all'         => \my $update_all,
14     'g|group=s'     => \my @update_groups,
15     'h|help'        => sub { pod2usage(0) },
16 ) or pod2usage(2);
17
18 die "Requires --storage\n"
19     unless defined $storage_dir;
20
21 die "Requires --config\n"
22     unless defined $config_file;
23
24 die "Requires --all or --group option\n"
25     unless $update_all or @update_groups;
26
27 my $config = System::Introspector::Config->new(
28     config_file => (defined($config_file)
29                     ? $config_file
30                     : "$storage_dir/main.conf"),
31 );
32
33 $config->has_group($_) or die "Unknown group '$_'\n"
34     for @update_groups;
35
36 @update_groups = $config->groups
37     if $update_all;
38
39 my $state = System::Introspector::State->new(
40     config => $config,
41     root   => $storage_dir,
42 );
43
44 $state->gather(@update_groups);
45
46 __END__
47
48 =head1 NAME
49
50 system-introspector - Generate System Introspection Data
51
52 =head1 SYNOPSIS
53
54     system-introspector --storage <path> [OPTIONS]
55
56 =head1 OPTIONS
57
58 =head2 -s <path>, --storage <path>
59
60 Path to storage. Always required.
61
62 =head2 -c <file>, --config <file>
63
64 Path to the configuration file.
65
66 =head2 -a, --all
67
68 Fetch all groups.
69
70 =head2 -g <group>, --group <group>
71
72 Fetch the specified group. Can be used multiple times.
73
74 =head2 -h, --help
75
76 Display help.
77
78 =cut