- my %o;
- getopts "l:t:", \%o and @ARGV == 0
- or Odin::fail "usage: new [-l LANG] [-t TITLE]";
- my %p = (title => decode(locale => $o{t}), lang => $o{l} // "txt",
- content => read_content);
+ my $op = Odin::OptParse->new(@ARGV);
+ my $p = (title => undef, lang => "txt");
+ while (my $o = $op->get) {
+ if ($o eq "l") { $p{lang} = $op->arg; }
+ elsif ($o eq "t") { $p{title} = decode locale => $op->arg; }
+ else { $op->unk; }
+ }
+ @ARGV = $op->rest;
+ $op->bad if @ARGV;
+ $op->ok or Odin::fail "usage: new [-l LANG] [-t TITLE]";
+ $p{content} = read_content;