NAME
Review::Helper::CLI::Serve - The review-helper serve subcommand.
DESCRIPTION
review-helper serve FILE [--port N | --port-command CMD] [--listen ADDR] [--allow-host NAME]... [--open] [--reviewer NAME]
review-helper FILE [--port N | --port-command CMD] [--listen ADDR] [--allow-host NAME]... [--open] [--reviewer NAME]
Serves the review in FILE as a web app (Review::Helper::Server) until interrupted, and prints the URL to open. By default it listens on 127.0.0.1 only.
--listen ADDR, or else the REVIEW_HELPER_LISTEN environment variable, listens on ADDR instead: an IPv4 or IPv6 address, or a host name that resolves to one of this machine's addresses. 0.0.0.0 listens on every IPv4 interface and :: on every IPv6 one (and usually IPv4 too). This is for reviewing from a browser on another machine, such as a laptop reaching a shared dev server. Beyond loopback the server accepts requests addressed to the address listened on (unless a wildcard), this machine's hostname and FQDN, the addresses they resolve to, and the address outgoing traffic leaves from, as well as 127.0.0.1, localhost and [::1]. Clients other than loopback must also present a random token made at start (see Review::Helper::Server); loopback clients need none. It prints a URL for other machines first, with the token: the FQDN for a wildcard, else ADDR as given. When the socket also answers on loopback (a wildcard), the loopback URL, without a token, follows. It warns on standard error that anyone with the token URL, and anyone on this machine, can read the review and post feedback.
--allow-host NAME (repeatable), plus the comma-separated names in the REVIEW_HELPER_ALLOW_HOSTS environment variable, are further host names to accept, such as a DNS alias or an address of another interface. A reverse proxy on this machine connects from loopback, so everyone who can reach the proxy gets in without the token.
The port is --port when given. Otherwise --port-command, or else the REVIEW_HELPER_PORT_COMMAND environment variable, names a command whose standard output is the port number, such as a script that hands out a port per worktree. The command is split on whitespace and run directly, not through a shell; put anything needing a shell in a script. With none of these, any free port is used.
With --open, also opens the URL with xdg-open on Linux or open on macOS: the loopback URL when there is one, else the only URL printed. Elsewhere the URL is only printed.
--reviewer names who is reviewing; the page records it on the feedback, requests and seen marks it writes. It defaults to the REVIEW_HELPER_REVIEWER environment variable, else Name <email> from git's user.name and user.email for the repository, else the login name, else unknown.
SYNOPSIS
Review::Helper::CLI->run(serve => $file, '--open');
PUBLIC METHODS
- Review::Helper::CLI::Serve->run($settings, $file)
-
Serve
$fileuntil the process is stopped. Dies unless exactly one file is given, on an invalid port, or when the address and port cannot be bound. - $port = Review::Helper::CLI::Serve->pick_port($port, $command)
-
The port to listen on, from
--portand--port-command(either may be undef), as described above; 0 means any free port. Dies when both are given. - $port = Review::Helper::CLI::Serve->run_port_command($command)
-
Run
$commandand return the port it printed. Dies when it cannot run, exits non-zero, or prints anything but a port number from 1 to 65535. - $socket = Review::Helper::CLI::Serve->listen_socket($port)
- $socket = Review::Helper::CLI::Serve->listen_socket($port, $listen)
-
A listening IO::Socket::IP on
$listen(default127.0.0.1), an address or a host name, port$port. Port 0 picks a free port;$socket->sockhostand$socket->sockportsay where it is bound. Dies when it cannot be bound. - $bool = Review::Helper::CLI::Serve->is_wildcard($addr)
-
True for
0.0.0.0and::, which listen on every interface. - @urls = Review::Helper::CLI::Serve->urls($listen, $bound, $port)
-
The URLs to print for a socket listening on
$listen, bound to the address$bound: for a loopback address, its URL; for another specific address, the URL with$listenas given; for a wildcard, the URL with this machine's FQDN, then the loopback URL ([::1]for::). IPv6 addresses are put in brackets. - $hex = Review::Helper::CLI::Serve->new_token()
-
64 hex digits from 32 bytes of /dev/urandom.
- $name = Review::Helper::CLI::Serve->fqdn()
-
This machine's fully qualified name, as the resolver gives it for Sys::Hostname's hostname, or the hostname when it gives none.
- @names = Review::Helper::CLI::Serve->network_names($listen, $bound)
-
The host names and addresses to accept when listening beyond loopback, as described above, without duplicates. Link-local addresses lose their zone.
- $bool = Review::Helper::CLI::Serve->open_browser($url)
-
Open
$urlin the desktop's browser. The opener runs detached, with no terminal output, and is not waited for, since some openers return only when the browser exits. Returns true once it is started, and false, without trying, on platforms other than Linux and macOS. When the opener cannot be run, a message goes to standard error. - Review::Helper::CLI::Serve->exec_detached($command, @args)
-
Run in a child process by
open_browser: fork, start a new session, point standard input, output and error at /dev/null, and exec$command. The calling process exits at once; it never returns.
SOURCE
The source code repository for Review-Helper can be found at https://github.com/exodist/Review-Helper.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.