Mercurial > hg > Members > anatofuz > slides
changeset 40:b887347d2d2b
auto-Update generated slides by script
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 May 2018 10:16:46 +0900 |
parents | 202d1ab8775a |
children | deed6fa2e489 |
files | lib/CLI.pm |
diffstat | 1 files changed, 21 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- 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;