@elefunc/send 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +16 -15
- package/src/tui/app.ts +2 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ const SELF_HELP_TEXT = "self identity: `name`, `name-id`, or `-id`"
|
|
|
60
60
|
const INVALID_SELF_ID_MESSAGE = `--self id suffix must be exactly ${SELF_ID_LENGTH} lowercase alphanumeric characters`
|
|
61
61
|
type CliCommand = ReturnType<CAC["command"]>
|
|
62
62
|
const ROOM_SELF_OPTIONS = [
|
|
63
|
-
["--room <room>", "room id
|
|
63
|
+
["--room <room>", "room id", { default: "<random>" }],
|
|
64
64
|
["--self <self>", SELF_HELP_TEXT],
|
|
65
65
|
] as const
|
|
66
66
|
const TURN_OPTIONS = [
|
|
@@ -69,16 +69,17 @@ const TURN_OPTIONS = [
|
|
|
69
69
|
["--turn-credential <value>", "custom TURN credential"],
|
|
70
70
|
] as const
|
|
71
71
|
const OVERWRITE_OPTION = ["--overwrite", "overwrite same-name saved files instead of creating copies"] as const
|
|
72
|
-
const SAVE_DIR_OPTION = ["--save-dir <dir>", "save directory"] as const
|
|
72
|
+
const SAVE_DIR_OPTION = ["--save-dir <dir>", "save directory", { default: "." }] as const
|
|
73
73
|
const TUI_TOGGLE_OPTIONS = [
|
|
74
|
-
["--clean <0|1>", "show only active peers when 1; show terminal peers too when 0"],
|
|
75
|
-
["--accept <0|1>", "auto-accept incoming offers: 1 on, 0 off"],
|
|
76
|
-
["--offer <0|1>", "auto-offer drafts to matching ready peers: 1 on, 0 off"],
|
|
77
|
-
["--save <0|1>", "auto-save completed incoming files: 1 on, 0 off"],
|
|
74
|
+
["--clean <0|1>", "show only active peers when 1; show terminal peers too when 0", { default: 1 }],
|
|
75
|
+
["--accept <0|1>", "auto-accept incoming offers: 1 on, 0 off", { default: 1 }],
|
|
76
|
+
["--offer <0|1>", "auto-offer drafts to matching ready peers: 1 on, 0 off", { default: 1 }],
|
|
77
|
+
["--save <0|1>", "auto-save completed incoming files: 1 on, 0 off", { default: 1 }],
|
|
78
78
|
] as const
|
|
79
79
|
export const ACCEPT_SESSION_DEFAULTS = { autoAcceptIncoming: true, autoSaveIncoming: true } as const
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
type CliOptionDefinition = readonly [flag: string, description: string, config?: { default?: unknown }]
|
|
81
|
+
const addOptions = (command: CliCommand, definitions: readonly CliOptionDefinition[]) =>
|
|
82
|
+
definitions.reduce((next, [flag, description, config]) => next.option(flag, description, config), command)
|
|
82
83
|
const withTrailingHelpLine = <T extends { outputHelp: () => void }>(target: T) => {
|
|
83
84
|
const outputHelp = target.outputHelp.bind(target)
|
|
84
85
|
target.outputHelp = () => {
|
|
@@ -316,24 +317,24 @@ export const createCli = (handlers: CliHandlers = defaultCliHandlers) => {
|
|
|
316
317
|
const cli = cac(name)
|
|
317
318
|
cli.usage("[command] [options]")
|
|
318
319
|
|
|
319
|
-
withTrailingHelpLine(addOptions(cli.command("peers", "list discovered peers"), [
|
|
320
|
+
withTrailingHelpLine(addOptions(cli.command("peers", "list discovered peers").ignoreOptionDefaultValue(), [
|
|
320
321
|
...ROOM_SELF_OPTIONS,
|
|
321
|
-
["--wait <ms>", "discovery wait in milliseconds"],
|
|
322
|
+
["--wait <ms>", "discovery wait in milliseconds", { default: 3000 }],
|
|
322
323
|
["--json", "print a json snapshot"],
|
|
323
324
|
SAVE_DIR_OPTION,
|
|
324
325
|
...TURN_OPTIONS,
|
|
325
326
|
])).action(handlers.peers)
|
|
326
327
|
|
|
327
|
-
withTrailingHelpLine(addOptions(cli.command("offer [...files]", "offer files to browser-compatible peers"), [
|
|
328
|
+
withTrailingHelpLine(addOptions(cli.command("offer [...files]", "offer files to browser-compatible peers").ignoreOptionDefaultValue(), [
|
|
328
329
|
...ROOM_SELF_OPTIONS,
|
|
329
|
-
["--to <peer>", "target `name`, `name-id`, or `-id
|
|
330
|
-
["--wait-peer <ms>", "wait for eligible peers in milliseconds
|
|
330
|
+
["--to <peer>", "target `name`, `name-id`, or `-id`", { default: "." }],
|
|
331
|
+
["--wait-peer <ms>", "wait for eligible peers in milliseconds", { default: "<infinite>" }],
|
|
331
332
|
["--json", "emit ndjson events"],
|
|
332
333
|
SAVE_DIR_OPTION,
|
|
333
334
|
...TURN_OPTIONS,
|
|
334
335
|
])).action(handlers.offer)
|
|
335
336
|
|
|
336
|
-
withTrailingHelpLine(addOptions(cli.command("accept", "receive and save files"), [
|
|
337
|
+
withTrailingHelpLine(addOptions(cli.command("accept", "receive and save files").ignoreOptionDefaultValue(), [
|
|
337
338
|
...ROOM_SELF_OPTIONS,
|
|
338
339
|
SAVE_DIR_OPTION,
|
|
339
340
|
OVERWRITE_OPTION,
|
|
@@ -342,7 +343,7 @@ export const createCli = (handlers: CliHandlers = defaultCliHandlers) => {
|
|
|
342
343
|
...TURN_OPTIONS,
|
|
343
344
|
])).action(handlers.accept)
|
|
344
345
|
|
|
345
|
-
withTrailingHelpLine(addOptions(cli.command("tui", "launch the interactive terminal UI"), [
|
|
346
|
+
withTrailingHelpLine(addOptions(cli.command("tui", "launch the interactive terminal UI").ignoreOptionDefaultValue(), [
|
|
346
347
|
...ROOM_SELF_OPTIONS,
|
|
347
348
|
...TUI_TOGGLE_OPTIONS,
|
|
348
349
|
["--events", "show the event log pane"],
|
package/src/tui/app.ts
CHANGED
|
@@ -1254,7 +1254,7 @@ const renderEventsCard = (state: TuiState, actions: TuiActions) => denseSection(
|
|
|
1254
1254
|
actionButton("clear-events", "Clear", actions.clearLogs, "warning", !state.snapshot.logs.length),
|
|
1255
1255
|
],
|
|
1256
1256
|
}, [
|
|
1257
|
-
ui.box({ maxHeight: 24, overflow: "scroll" }, [
|
|
1257
|
+
ui.box({ id: "events-viewport", maxHeight: 24, overflow: "scroll", border: "none" }, [
|
|
1258
1258
|
state.snapshot.logs.length
|
|
1259
1259
|
? ui.column({ gap: 0 }, state.snapshot.logs.slice(0, 20).map(renderLogRow))
|
|
1260
1260
|
: ui.empty("No events"),
|
|
@@ -1301,7 +1301,7 @@ export const renderTuiView = (state: TuiState, actions: TuiActions): VNode => {
|
|
|
1301
1301
|
...transferCards,
|
|
1302
1302
|
]),
|
|
1303
1303
|
]),
|
|
1304
|
-
state.eventsExpanded ? ui.box({ id: "events-shell", width: 28, minHeight: 0 }, [renderEventsCard(state, actions)]) : null,
|
|
1304
|
+
state.eventsExpanded ? ui.box({ id: "events-shell", width: 28, minHeight: 0, border: "none" }, [renderEventsCard(state, actions)]) : null,
|
|
1305
1305
|
]),
|
|
1306
1306
|
footer: renderFooter(state),
|
|
1307
1307
|
p: 0,
|