1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! Shared `dialoguer` prompt helpers used by every binary's setup wizard.
//!
//! Why this module exists: the four binary wizards (server, control,
//! daemon, witness) previously duplicated the same prompt patterns inline
//! — listen host/port, log format, public URL — and across two setup
//! modes each (online + offline) in some cases. A typo or default-value
//! drift between binaries was easy to introduce and hard to spot.
//!
//! Helpers here are intentionally minimal — they wrap a single dialoguer
//! call each, take an explicit default value so the call site documents
//! the per-binary default, and return the parsed/validated result. No
//! behaviour change vs. the inline form; the value is consolidation.
//!
//! The setup wizards for the offline-bootstrap secret store live in
//! `super::secret_store::wizard` and are not affected — different
//! prompt surface entirely.
use ;
use ;
/// Prompt for a long, free-form value (DIDs, URLs) that can exceed the
/// terminal width.
///
/// `dialoguer::Input::interact_text()` renders the prompt and the typed
/// value inline and redraws the line on submit, but its render-height
/// tracker counts only `\n` characters (`dialoguer`'s `theme/render.rs`),
/// so it cannot see that a long value wrapped onto a second physical row on
/// a narrow terminal. Its post-submit `clear_last_lines` then under-counts,
/// the wrapped first row is never erased, and the redraw leaves a duplicate
/// — the doubled `Mediator DID` line operators hit when the value is wider
/// than the window. We sidestep the redraw entirely: print the label and
/// read the line in cooked mode, letting the terminal wrap the echo
/// naturally with nothing to clear. The on-screen form (`prompt: value`)
/// matches `dialoguer`'s default `SimpleTheme`.
///
/// `allow_empty` controls whether an empty submission returns `""` (used by
/// "leave empty to skip" prompts) or re-prompts. EOF returns whatever was
/// read so a non-interactive stream can't spin forever. The result is
/// trimmed.
/// Prompt for a public URL.
///
/// `prompt_text` lets the caller phrase the question for its binary
/// (e.g. "Server URL", "DID hosting URL"). The trailing slash is
/// stripped before returning so downstream code can `format!("{}/path")`
/// without double-slashing.
/// Prompt for the bind / listen host. Default is almost always `0.0.0.0`
/// (any interface); pass that in to keep the call site's intent visible.
/// Prompt for the bind / listen port. Default differs per binary
/// (server=8530, daemon=8534, witness=8102, …); pass the binary's choice.
/// Prompt for the log output format (`text` or `json`). Default is `text`.
/// Prompt for which messaging transport(s) the node advertises and its
/// mediator listener carries. TSP and DIDComm share the mediator socket,
/// so callers only invoke this when a mediator has been configured — with
/// no mediator the node is HTTP-only. Defaults to `Both` (a node that
/// speaks both is reachable by every peer; TSP is preferred when a peer
/// advertises both).