Skip to content

Commit

Permalink
Serge: display version information with the --version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
julen committed Oct 25, 2016
1 parent efe5689 commit e6271d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Revision history
- When job fails, we now move on to the next job in the config
(previously the entire config would be skipped)

- Added version information to the CLI via the `--version` flag (#38)

1.1 April 20, 2016

- On OS X, expand `~` to the actual `$HOME` path in SQLite DB connection string (#1)
Expand Down
12 changes: 10 additions & 2 deletions lib/Serge/Application.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use File::Find qw(find);
use File::Spec::Functions qw(rel2abs catfile);
use Getopt::Long qw(:config no_auto_abbrev no_ignore_case pass_through);
use Serge::Config::Collector;
use Serge;

sub new {
my ($class) = @_;
Expand All @@ -24,12 +25,19 @@ sub new {
sub run {
my ($self) = @_;

my ($help, $debug);
my ($help, $debug, $version);
my $result = GetOptions(
'help' => \$help,
'debug' => \$debug,
'version|V' => \$version,
);

# print out version when passing the flat to a bare `serge` command
if ($version && !@ARGV[0]) {
print "Serge $Serge::VERSION\n";
exit(0);
}

if (!$result) {
$self->error("Failed to parse some command-line parameters.");
}
Expand Down Expand Up @@ -172,4 +180,4 @@ sub error {
exit($exitstatus);
}

1;
1;

0 comments on commit e6271d4

Please sign in to comment.