Skip to content

Commit

Permalink
Usage info when --help provided
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelruiz committed Jan 11, 2013
1 parent 0fc1a21 commit 7dc8e73
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/App/cart.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ sub config {
'c|conffile=s' => \$self->{conffile},
'p|pidfile=s' => \$self->{pidfile},
'l|loglevel=s' => \$self->{loglevel},
'help' => \$self->{help},
) or die "Error parsing options\n";

if ($self->{help}) {
_usage();
exit 0;
};

my $command = $self->{command} = shift @{ $self->{options} } || 'start';

if ( !-d $self->{home}
Expand Down Expand Up @@ -194,4 +200,30 @@ CONF
$log->debug("Dumped conf file to '$self->{home}/$self->{conffile}'");
}

sub _usage {
print <<USG;
Usage: $0 [options] [command]
Commands:
-h, --home path where config, tweet db and pid file are
-c, --conffile path to conffile. Defaults to \$HOME/.cart/cart.yml
-p, --pidfile defaults to \$HOME/.cart/cart.pid
-l, --loglevel accepted values:
trace
debug
info (inform)
notice
warning (warn)
error (err)
critical (crit, fatal)
alert
emergency
Options:
start Starts the service. Default if no command specified
init Initializes the home directory
USG
}

1;

0 comments on commit 7dc8e73

Please sign in to comment.