Skip to content

Commit e4cc3c1

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`. We’re only supporting the long `--host` option because `-h` already means `--help`.
1 parent f8be787 commit e4cc3c1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ import Foundation
1717
public struct PreviewOptions: ParsableArguments {
1818
public init() { }
1919

20+
/// The host name to use for the preview web server.
21+
///
22+
/// Defaults to `localhost`.
23+
@Option(
24+
name: .long,
25+
help: ArgumentHelp(
26+
"Host name to use for the preview web server.",
27+
valueName: "host-name"))
28+
public var host: String = "localhost"
29+
2030
/// The port number to use for the preview web server.
2131
///
2232
/// 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)