use DisOrder;
use File::FcntlLock;
+use Getopt::Long qw{:config gnu_compat bundling
+ require_order no_getopt_compat};
use POSIX qw{:errno_h :fcntl_h};
###--------------------------------------------------------------------------
lockdir => "$ENV{HOME}/.disorder/",
mixer => "Master,0");
+(my $PROG = $0) =~ s:^.*/::;
my $TITLE = "DisOrder";
my $VARIANT = "default";
if (-l $C{config} && (my $t = readlink $C{config}) =~ /^passwd\.(.*)$/)
###--------------------------------------------------------------------------
### Main program.
-if (@ARGV != 1) { print STDERR "usage: $0 OP\n"; exit 2; }
+sub usage (\*) {
+ my ($fh) = @_;
+ print $fh "usage: $PROG [-u CONFIG] COMMAND\n";
+}
+
+sub help () {
+ usage *STDOUT;
+ print <<EOF;
+
+Command-line options:
+ -h, --help Show this help text
+ -u, --user-config Set user configuration file
+
+Commands:
+ volume-up
+ volume-down
+ scratch
+ enable/disable
+ play/pause
+ watch
+ now-playing
+ notify-now-playing
+ next-config
+EOF
+}
+
+my $bad = 0;
+GetOptions
+ "h|help" => sub { help; exit 0; },
+ "u|user-config=s" => \$C{config}
+ or $bad = 1;
+@ARGV == 1 or $bad = 1;
+if ($bad) { usage *STDERR; exit 2; }
my $op = $ARGV[0];
if (!exists $OP{$op}) { print STDERR "$0: unknown op `$op'\n"; exit 2; }
$OP{$op}();