#!/usr/local/bin/perl
# ABSTRACT: CLI runner for MCP::Wiki server
# PODNAME: mcp-wiki

use strict;
use warnings;
use MCP::Wiki::Server;
use Getopt::Long;
use Pod::Usage;

my $wiki_root = '.';
my $use_git = 0;
my $commit_reason_required = 0;
my $help = 0;

GetOptions(
    'wiki-root=s' => \$wiki_root,
    'git' => \$use_git,
    'commit-reason-required' => \$commit_reason_required,
    'help' => \$help,
) or pod2usage(2);

pod2usage(1) if $help;

my $server = MCP::Wiki::Server->new(
    wiki_root => $wiki_root,
    use_git => $use_git,
    commit_reason_required => $commit_reason_required,
);

if ($use_git) {
    $server->on_change(sub {
        my $ev = shift;
        warn "on_change fired: $ev->{type} on $ev->{page}";
    });
}

$server->to_stdio;

__END__

=pod

=encoding UTF-8

=head1 NAME

mcp-wiki - CLI runner for MCP::Wiki server

=head1 VERSION

version 0.001

=head1 SYNOPSIS

    mcp-wiki --wiki-root /path/to/wiki --git

=head1 OPTIONS

=over 4

=item B<--wiki-root>

Root directory for wiki pages (default: current directory)

=item B<--git>

Enable git auto-commit on changes

=item B<--commit-reason-required>

Require a reason for commits

=item B<--help>

Show this help message

=back

=head1 SUPPORT

=head2 Issues

Please report bugs and feature requests on GitHub at
L<https://github.com/Getty/p5-mcp-wiki/issues>.

=head1 CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

=head1 AUTHOR

Torsten Raudssus <getty@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
