Skip to content

Commit 68c0228

Browse files
committed
Add --host option to PreviewOptions
This retains the `localhost` default host name for the preview server, but allows the user to override it by providing `--host`.
1 parent 1a1b249 commit 68c0228

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Sources/SwiftDocCUtilities/ArgumentParsing/ActionExtensions/PreviewAction+CommandInitialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension PreviewAction {
2424
{
2525
// Initialize the `PreviewAction` from the options provided by the `Preview` command
2626
try self.init(
27-
host: "localhost",
27+
host: previewOptions.host,
2828
port: previewOptions.port,
2929
createConvertAction: {
3030
try ConvertAction(

Sources/SwiftDocCUtilities/ArgumentParsing/Options/PreviewOptions.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ import Foundation
1717
public struct PreviewOptions: ParsableArguments {
1818
public init() { }
1919

20+
@Option(
21+
name: .shortAndLong,
22+
help: ArgumentHelp(
23+
"Host name to use for the preview web server.",
24+
valueName: "host-name"))
25+
public var host: String = "localhost"
26+
2027
/// The port number to use for the preview web server.
2128
///
2229
/// Defaults to `8080`.

Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/Preview.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ extension Docc {
2323
public static var configuration = CommandConfiguration(
2424
abstract: "Convert documentation inputs and preview the documentation output.",
2525
usage: """
26-
docc preview [<catalog-path>] [--port <port-number>] [--additional-symbol-graph-dir <symbol-graph-dir>]
27-
docc preview [<catalog-path>] [--port <port-number>] [--additional-symbol-graph-dir <symbol-graph-dir>] [--output-dir <output-dir>]
28-
docc preview [<catalog-path>] [--port <port-number>] [--additional-symbol-graph-dir <symbol-graph-dir>] [--output-dir <output-dir>] [<availability-options>] [<diagnostic-options>] [<source-repository-options>] [<hosting-options>] [<info-plist-fallbacks>] [<feature-flags>] [<other-options>]
26+
docc preview [<catalog-path>] [--host <host-name>] [--port <port-number>] [--additional-symbol-graph-dir <symbol-graph-dir>]
27+
docc preview [<catalog-path>] [--host <host-name>] [--port <port-number>] [--additional-symbol-graph-dir <symbol-graph-dir>] [--output-dir <output-dir>]
28+
docc preview [<catalog-path>] [--host <host-name>] [--port <port-number>] [--additional-symbol-graph-dir <symbol-graph-dir>] [--output-dir <output-dir>] [<availability-options>] [<diagnostic-options>] [<source-repository-options>] [<hosting-options>] [<info-plist-fallbacks>] [<feature-flags>] [<other-options>]
2929
""",
3030
discussion: """
3131
The 'preview' command extends the 'convert' command by running a preview server and monitoring the documentation input for modifications to rebuild the documentation.

0 commit comments

Comments
 (0)