From 7eda8a29d24a65b068815d27f92ac4f16969853d Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 30 Aug 2022 21:44:24 -0600 Subject: [PATCH] command-line: Add manpage and completion --- src/docs/markdown/command-line.md | 46 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/src/docs/markdown/command-line.md b/src/docs/markdown/command-line.md index 38cd195..8f02610 100644 --- a/src/docs/markdown/command-line.md +++ b/src/docs/markdown/command-line.md @@ -16,7 +16,7 @@ The`[brackets]` indicate optional parameters. The ellipses `...` indicates a continuation, i.e. one or more parameters. -**Quick start: `caddy help`** +**Quick start: `caddy`, `caddy help`, or `man caddy` (if installed)** --- @@ -25,7 +25,10 @@ The ellipses `...` indicates a continuation, i.e. one or more parameters. - **[caddy build-info](#caddy-build-info)** Prints build information - + +- **[caddy completion](#caddy-completion)** + Generate shell completion script + - **[caddy environ](#caddy-environ)** Prints the environment @@ -44,6 +47,9 @@ The ellipses `...` indicates a continuation, i.e. one or more parameters. - **[caddy list-modules](#caddy-list-modules)** Lists the installed Caddy modules +- **[caddy manpage](#caddy-manpage)** + Generate manpages + - **[caddy reload](#caddy-reload)** Changes the config of the running Caddy process @@ -146,6 +152,17 @@ Prints information provided by Go about the build (main module path, package ver + +### `caddy completion` + +
caddy completion [bash|zsh|fish|powershell]
+ +Generates shell completion scripts. This allows you to get tab-complete or auto-complete (or similar, depending on your shell) when typing `caddy` commands. + +To get instructions for installing this script into your specific shell, run `caddy help completion` or `caddy completion -h`. + + + ### `caddy environ`
caddy environ
@@ -240,6 +257,29 @@ NOTE: Due to [a bug in Go](https://github.com/golang/go/issues/29228), version i +### `caddy manpage` + +
caddy manpage
+	--directory <path>
+ +Generates manual/documentation pages for Caddy commands and writes them to the directory at the specified path. The output of this command can be read by the `man` command. + +`--directory` (required) is the path to the directory into which to write the man pages. It will be created if it does not exist. + +Once generated, the manual pages generally need to be installed. This procedure varies by platform, but on typical Linux systems, it's something like this: + +
$ caddy manpage --directory man
+$ gzip -r man/
+$ sudo cp man/* /usr/share/man/man8/
+$ sudo mandb
+
+ +Then you can run `man caddy` (or `man caddy-*` for subcommands) to read documentation in your terminal. + +Manual pages are separate documentation from what is on our website. Our website has more comprehensive documentation that is updated often. + + + ### `caddy reload`
caddy reload
@@ -318,7 +358,7 @@ Server address: [::]:2003
 Server address: [::]:2004
 
 $ curl 127.0.0.1:2002
-I'm server 2 on port 2002
+I'm server 2 on port 2002 Pipe in a maintenance page:
cat maintenance.html | caddy respond \