#!/usr/bin/env perl

# Thin wrapper: everything, including error reporting and the exit code,
# lives in App::FileSync::CLI so it can be tested without a subprocess.

use strict;
use warnings;
use autodie qw(:all);

use FindBin qw($Bin);

# A checkout's lib/ first, so bin/ runs the code beside it; an installed
# copy finds the modules on @INC as usual.
use lib "$Bin/../lib";

use App::FileSync::Platform;
use App::FileSync::CLI;

exit App::FileSync::CLI::run_server(@ARGV);

__END__

=head1 NAME

filesync-server - serve one sync session (the forced command in authorized_keys)

=head1 SYNOPSIS

	command="filesync-server --repo docs --client laptop --role client" ssh-ed25519 AAAA...

It is not run by hand: sshd starts it with the arguments pinned in F<authorized_keys>.

=head1 DESCRIPTION

See L<App::FileSync::CLI> and L<App::FileSync>.

=head1 EXIT STATUS

0 when the session finished; 1 when it did not, for any reason: a bad or
missing argument, a forced command that does not match the arguments, a
terminal on standard input, a protocol error, a refused request, or another
session holding the repo's lock.  The client reports the error the server
sent it; the server's journal records the failed session (with C<exit> 2 for
a lock refusal).

=head1 AUTHOR

Nigel Horne, C<< <njh at nigelhorne.com> >>

=head1 LICENCE AND COPYRIGHT

Copyright 2026 Nigel Horne.

Usage is subject to the GPL2 licence terms.
If you use it,
please let me know.

=cut
