# HG changeset patch # User Takahiro SHIMIZU # Date 1525742206 -32400 # Node ID b887347d2d2b671b5de84709cd66ac96148a9ed4 # Parent 202d1ab8775ae4a3ab2627ecadef6fc6b07d4a10 auto-Update generated slides by script diff -r 202d1ab8775a -r b887347d2d2b lib/CLI.pm --- a/lib/CLI.pm Mon May 07 13:12:49 2018 +0900 +++ b/lib/CLI.pm Tue May 08 10:16:46 2018 +0900 @@ -23,30 +23,30 @@ file => { describe => 'target file', alias => 'f'} ); $opt->subcmd( - new => Smart::Options->new(), - build => Smart::Options->new(), - open => Smart::Options->new->default('target' => 'slide.md'), - 'build_open' => Smart::Options->new->default('target' => 'slide.md'), - upload => Smart::Options->new(), - memo => Smart::Options->new(), - edit => Smart::Options->new(), - zip => Smart::Options->new(), + new => Smart::Options->new(), + build => Smart::Options->new(), + open => Smart::Options->new->default('target' => 'slide.md'), + build_open => Smart::Options->new->default('target' => 'slide.md'), + upload => Smart::Options->new(), + memo => Smart::Options->new(), + edit => Smart::Options->new(), + zip => Smart::Options->new(), ); - my $result = $opt->parse(@args); + my $result = $opt->parse(@args); my $command = $result->{command} // "open"; - my $option = $result->{cmd_option}->{f} || $result->{cmd_option}->{file} || 0; + my $option = $result->{cmd_option}->{f} || $result->{cmd_option}->{file} || 0; - my $call= $self->can("cmd_$command"); + my $call = $self->can("cmd_$command"); croak 'undefine subcommand' unless $call; $self->$call($option); } sub cmd_new { - my ($self) = @_; + my ($self) = @_; my ($y,$m,$d) = _y_m_d(); - my $slide = path($self->root_dir)->child($y)->child($m)->child($d)->child('slide.md')->touchpath; + my $slide = path($self->root_dir)->child($y)->child($m)->child($d)->child('slide.md')->touchpath; path($self->template)->copy($slide); } @@ -140,26 +140,26 @@ } sub _search_recently_day { - my($self) = @_; + my ($self) = @_; my ($y,$m,$d) = _y_m_d(); - my $root_dir = path($self->root_dir)->child($y)->child($m); + my $root_dir = path($self->root_dir)->child($y)->child($m); - my $date = shift @{ [sort { $b->stat->mtime <=> $a->stat->mtime } $root_dir->children]}; + my $date = shift @{ [sort { $b->stat->mtime <=> $a->stat->mtime } $root_dir->children]}; return $date; } sub cmd_memo { - my ($self) = @_; + my ($self) = @_; my ($y,$m,$d) = _y_m_d(); - my $memo = path($self->root_dir)->child($y)->child($m)->child($d)->child('memo.txt')->touchpath; + my $memo = path($self->root_dir)->child($y)->child($m)->child($d)->child('memo.txt')->touchpath; exec $ENV{EDITOR},($memo->realpath); } sub cmd_edit { - my ($self) = @_; + my ($self) = @_; my $recent_day = $self->_search_recently_day(); - my @targets = $recent_day->children(qr/\.md$/); - my $target = pop @targets; + my @targets = $recent_day->children(qr/\.md$/); + my $target = pop @targets; exec $ENV{EDITOR},($target->realpath); } @@ -187,5 +187,4 @@ } } - 1;