-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk_blog.pl
executable file
·61 lines (41 loc) · 1.05 KB
/
mk_blog.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/perl -w
use strict;
use Getopt::Std;
use Data::Dumper;
use Blog qw/ :all /;
# global options
use vars qw/ %opt /;
my $opt_string = 'pf:c:';
getopts( "$opt_string", \%opt ) or usage();
my $config = read_config($opt{'c'});
my $entry_dir = $config->{"entry_dir"};
my $entry_file = "";
if ($opt{'f'} ) {
$entry_file = $opt{'f'} ;
print "$entry_dir$entry_file\n";
} else {
die "You must specify an entry_file\n";
}
my $complete_filename = $config->{'entry_dir'}.$entry_file;
my ($result, $meta) = make_blog_entry($complete_filename, $config);
if ($opt{p}) {
print $result->{"result"};
} else {
output_blog_file($result, $config, $meta);
}
1;
#
# Message about this program and how to use it
#
sub usage {
print STDERR << "EOF";
Formats blog enties.
usage: $0 [-h?c] -f individual_entry
-h|? : this (help) message
-f file : input file
-c config : configuration file
-p : print result instead of saving
example: $0 -p -c ~/Documents/blogging/tm/config.yml -f 2016/02/22/tm-102306.html
EOF
exit;
}