-my $dir=IkiWiki::dirname($pagefile);
-$dir="." unless length $dir;
-my $page=IkiWiki::basename($pagefile);
-if (! -d $pagefile) {
- $page=~s/\.[^.]+$//;
-}
+ my $dir=get_dir($pagefile);
+ my $page=get_page($pagefile);
+
+ IkiWiki::Plugin::comments::checkconfig();
+
+ if ($interactive) {
+ $format ||= 'mdwn';
+ $username ||= get_username();
+ $subject ||= get_subject($page, $dir);
+ $date ||= get_date();
+ } else {
+ $format ||= undef;
+ die "must supply username" unless defined $username;
+ $subject ||= get_subject($page, $dir);
+ die "must supply date" unless defined $date;
+ chomp($content = join('', <STDIN>));
+ }
+
+ my $comment=get_comment($format, $username, $subject, $date, $content);