Commit | Line | Data |
b549a663 |
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, |
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 |
18 | die "Requires --storage\n" |
19 | unless defined $storage_dir; |
20 | |
21 | die "Requires --config\n" |
22 | unless defined $config_file; |
23 | |
b549a663 |
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; |
b079a95d |
38 | |
39 | my $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 | |
50 | system-introspector - Generate System Introspection Data |
51 | |
52 | =head1 SYNOPSIS |
53 | |
54 | system-introspector --storage <path> [OPTIONS] |
55 | |
f24afb0e |
56 | =head1 DESCRIPTION |
57 | |
58 | See L<System::Introspector/DESCRIPTION> for more details. |
59 | |
b549a663 |
60 | =head1 OPTIONS |
61 | |
62 | =head2 -s <path>, --storage <path> |
63 | |
64 | Path to storage. Always required. |
65 | |
b6f45e4f |
66 | =head2 -c <file>, --config <file> |
67 | |
68 | Path to the configuration file. |
69 | |
70 | =head2 -a, --all |
b549a663 |
71 | |
b6f45e4f |
72 | Fetch all groups. |
b549a663 |
73 | |
b6f45e4f |
74 | =head2 -g <group>, --group <group> |
b549a663 |
75 | |
b6f45e4f |
76 | Fetch the specified group. Can be used multiple times. |
b549a663 |
77 | |
78 | =head2 -h, --help |
79 | |
80 | Display help. |
81 | |
f24afb0e |
82 | =head1 COPYRIGHT |
83 | |
84 | Copyright (c) 2012 the L<System::Introspector> |
85 | L<AUTHOR|System::Introspector/AUTHOR>, |
86 | L<CONTRIBUTORS|System::Introspector/CONTRIBUTORS> and |
87 | L<SPONSORS|System::Introspector/SPONSORS>. |
88 | |
89 | =head1 LICENSE |
90 | |
91 | This library is free software and may be distributed under the same terms |
92 | as perl itself. |
93 | |
b549a663 |
94 | =cut |