@boy-offi9-inc/tidepull 0.8.0 → 0.8.1

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/dist/main.js CHANGED
@@ -107,6 +107,16 @@ function listEntries(p) {
107
107
  p.entries.forEach((e, i) => rows.push([String(i + 1), e.title ?? "", e.url]));
108
108
  return table(rows);
109
109
  }
110
+ function renderHelp(theme, color) {
111
+ const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
112
+ const accent = (s) => (plain ? s : theme.accent + s + theme.reset);
113
+ const lines = HELP.split("\n");
114
+ return [
115
+ renderBanner(VERSION, theme, color),
116
+ "",
117
+ ...lines.map((l) => (l.startsWith("Usage:") ? accent(l) : l)),
118
+ ].join("\n");
119
+ }
110
120
  export async function main(argv) {
111
121
  let values;
112
122
  let positionals;
@@ -173,7 +183,7 @@ export async function main(argv) {
173
183
  return 2;
174
184
  }
175
185
  if (values.help)
176
- return void process.stdout.write(HELP + "\n"), 0;
186
+ return void process.stdout.write(renderHelp(pickTheme(values.theme), !values["no-color"] && shouldUseColor()) + "\n"), 0;
177
187
  if (values.version)
178
188
  return void process.stdout.write(VERSION + "\n"), 0;
179
189
  let theme;
@@ -185,8 +195,8 @@ export async function main(argv) {
185
195
  return 2;
186
196
  }
187
197
  const machineMode = values.quiet || values["dump-json"] || values["get-url"] || values.simulate || values["progress-json"];
188
- const interactiveStdout = process.stdout.isTTY && !machineMode && !values["list-extractors"];
189
- let showBanner = false;
198
+ const interactiveStdout = process.stdout.isTTY && !machineMode;
199
+ let showBanner = interactiveStdout;
190
200
  const log = new Logger({
191
201
  quiet: values.quiet,
192
202
  verbose: values.verbose,
@@ -241,7 +251,7 @@ export async function main(argv) {
241
251
  log.error(errMsg(e));
242
252
  return e instanceof TidepullError ? e.exitCode : 1;
243
253
  }
244
- showBanner = interactiveStdout && urls.length > 0;
254
+ showBanner = interactiveStdout && !values["list-extractors"];
245
255
  if (showBanner) {
246
256
  const pluginNames = plugins.map((p) => p.name);
247
257
  process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor(), pluginNames) + "\n");
package/dist/ui/banner.js CHANGED
@@ -3,15 +3,37 @@ const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
3
3
  function termWidth() {
4
4
  return process.stdout.columns ?? 80;
5
5
  }
6
- function infoRows(version, theme, plain, plugins) {
6
+ function infoRows(version, theme, plain, plugins, valueRoom) {
7
7
  const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
8
8
  const ok = (s) => (plain ? s : theme.success + s + theme.reset);
9
9
  const tag = (s) => (plain ? s : theme.tag + s + theme.reset);
10
+ const fit = (s, plain_s) => {
11
+ if (visible(plain_s) <= valueRoom)
12
+ return s;
13
+ if (plugins.length > 1 && plain_s === plugins.join(", ")) {
14
+ let names = plugins;
15
+ do {
16
+ names = names.slice(0, -1);
17
+ const body = names.join(", ") + ` +${plugins.length - names.length}`;
18
+ if (visible(body) <= valueRoom)
19
+ return tag(body);
20
+ } while (names.length > 1);
21
+ const one = plugins[0].slice(0, Math.max(1, valueRoom - 1)) + "\u2026";
22
+ return tag(one);
23
+ }
24
+ return s;
25
+ };
10
26
  const rows = [
11
27
  ["media downloader", ok(`v${version}`)],
12
28
  ["stdout", ok("data only")],
13
29
  ];
14
- rows.push(["plugins", plugins.length ? tag(plugins.join(", ")) : dim("none")]);
30
+ const pluginValue = plugins.length ? plugins.join(", ") : "";
31
+ if (plugins.length) {
32
+ rows.push(["plugins", fit(tag(pluginValue), pluginValue)]);
33
+ }
34
+ else {
35
+ rows.push(["plugins", dim("none")]);
36
+ }
15
37
  return rows;
16
38
  }
17
39
  export function renderBanner(version, theme, color = true, plugins = [], width) {
@@ -19,10 +41,22 @@ export function renderBanner(version, theme, color = true, plugins = [], width)
19
41
  const paint = (c, s) => (plain ? s : c + s + theme.reset);
20
42
  const accent = (s) => paint(theme.accent, s);
21
43
  const dim = (s) => paint(theme.dim, s);
22
- const w = Math.max(24, Math.min(width ?? termWidth(), 60));
23
- const rows = infoRows(version, theme, plain, plugins);
24
- const LABEL = Math.max(...rows.map(([k]) => k.length)) + 2;
44
+ const w = Math.min(width ?? termWidth(), 60);
25
45
  const inner = w - 2;
46
+ const LABEL = 17;
47
+ if (inner - 2 - LABEL < 10) {
48
+ const full = `${GLYPH} tidepull ${version}`;
49
+ const title = visible(full) > inner - 5
50
+ ? full.slice(0, Math.max(1, inner - 6)) + "\u2026"
51
+ : full;
52
+ const dash = "\u2500";
53
+ const fill = Math.max(1, inner - visible(title) - 4);
54
+ return [
55
+ accent("\u250c\u2500" + " ") + title + " " + accent(" " + dash.repeat(fill) + "\u2510"),
56
+ accent("\u2514" + dash.repeat(inner) + "\u2518"),
57
+ ].join("\n");
58
+ }
59
+ const rows = infoRows(version, theme, plain, plugins, inner - 2 - LABEL);
26
60
  const lines = [];
27
61
  const title = `${GLYPH} tidepull` + (plain ? ` v${version}` : ` ${paint(theme.dim, `v${version}`)}`);
28
62
  const shownTitle = visible(title) > inner - 4 ? `${GLYPH} tidepull` : title;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "A minimal, from-scratch media downloader library: extractor plugins, yt-dlp-style format selection, resumable downloads.",
5
5
  "type": "module",
6
6
  "license": "MIT",