added executable to makefile
[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 --all or --group option\n"
19     unless $update_all or @update_groups;
20
21 my $config = System::Introspector::Config->new(
22     config_file => (defined($config_file)
23                     ? $config_file
24                     : "$storage_dir/main.conf"),
25 );
26
27 $config->has_group($_) or die "Unknown group '$_'\n"
28     for @update_groups;
29
30 @update_groups = $config->groups
31     if $update_all;
32
33 my $state = System::Introspector::State->new(
34     config => $config,
35     root   => $storage_dir,
36 );
37
38 $state->gather(@update_groups);
39
40 __END__
41
42 =head1 NAME
43
44 system-introspector - Generate System Introspection Data
45
46 =head1 SYNOPSIS
47
48     system-introspector --storage <path> [OPTIONS]
49
50 =head1 OPTIONS
51
52 =head2 -s <path>, --storage <path>
53
54 Path to storage. Always required.
55
56 =head2 -H <host>, --host <host>
57
58 Remote host gathering
59
60 =head2 --allow-empty
61
62 Allow empty commits to storage.
63
64 =head2 -h, --help
65
66 Display help.
67
68 =cut