fixed perl filtering
[scpubgit/System-Introspector.git] / bin / system-introspector
CommitLineData
b549a663 1#!/usr/bin/env perl
2use strictures 1;
3
4use Getopt::Long;
5use Pod::Usage;
6use System::Introspector::State;
7use File::Tree::Snapshot;
8use System::Introspector::Config;
9
10GetOptions(
11 'c|config=s' => \my $config_file,
12 's|storage=s' => \my $storage_dir,
b549a663 13 'a|all' => \my $update_all,
14 'g|group=s' => \my @update_groups,
15 'h|help' => sub { pod2usage(0) },
16) or pod2usage(2);
17
b6f45e4f 18die "Requires --storage\n"
19 unless defined $storage_dir;
20
21die "Requires --config\n"
22 unless defined $config_file;
23
b549a663 24die "Requires --all or --group option\n"
25 unless $update_all or @update_groups;
26
27my $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;
b079a95d 38
39my $state = System::Introspector::State->new(
40 config => $config,
41 root => $storage_dir,
42);
43
44$state->gather(@update_groups);
b549a663 45
46__END__
47
48=head1 NAME
49
50system-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
60Path to storage. Always required.
61
b6f45e4f 62=head2 -c <file>, --config <file>
63
64Path to the configuration file.
65
66=head2 -a, --all
b549a663 67
b6f45e4f 68Fetch all groups.
b549a663 69
b6f45e4f 70=head2 -g <group>, --group <group>
b549a663 71
b6f45e4f 72Fetch the specified group. Can be used multiple times.
b549a663 73
74=head2 -h, --help
75
76Display help.
77
78=cut