newsline-cli 0.1.6 → 0.1.8

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/README.md CHANGED
@@ -29,7 +29,7 @@ npm i -g newsline-cli && newsline init
29
29
  /plugin install newsline@itdar
30
30
  ```
31
31
 
32
- The news line appears on your **next message** — no restart. Setup asks for a language & topic
32
+ The news line appears on your **next message** — no restart. Setup asks for a language, topic & headline color
33
33
  and keeps your existing status line.
34
34
 
35
35
  ## What it does
@@ -70,6 +70,10 @@ Re-run `newsline init`, or edit `~/.config/newsline/config.json`:
70
70
  | `count` | `15` | headlines in rotation |
71
71
  | `maxlen` | `120` | max characters (`max` = no cut) |
72
72
  | `icon` | `📰` | leading glyph (`none` to hide) |
73
+ | `color` | `white` | headline color: `default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
74
+
75
+ Or run `newsline color` — each run steps to the next color (default(gray) → white →
76
+ cyan → yellow → green → blue → magenta → red), shown on the next status-line tick.
73
77
 
74
78
  ## Uninstall
75
79
 
package/newsline CHANGED
@@ -77,8 +77,8 @@ load_config() {
77
77
  import json,sys,shlex
78
78
  env={"lang":"NEWSLINE_LANG","topic":"NEWSLINE_TOPIC","rotate":"NEWSLINE_ROTATE",
79
79
  "count":"NEWSLINE_COUNT","maxlen":"NEWSLINE_MAXLEN","icon":"NEWSLINE_ICON",
80
- "linkhint":"NEWSLINE_LINKHINT","api":"NEWSLINE_API","endpoint":"NEWSLINE_ENDPOINT",
81
- "base_statusline":"NEWSLINE_BASE"}
80
+ "color":"NEWSLINE_COLOR","linkhint":"NEWSLINE_LINKHINT","api":"NEWSLINE_API",
81
+ "endpoint":"NEWSLINE_ENDPOINT","base_statusline":"NEWSLINE_BASE"}
82
82
  try: d=json.load(open(sys.argv[1]))
83
83
  except Exception: d={}
84
84
  for k,name in env.items():
@@ -152,7 +152,7 @@ cmd_once() {
152
152
  }
153
153
 
154
154
  cmd_init() {
155
- local lang="" topic="" api="" endpoint="" rotate="6" count="15" compose="auto" yes="0" base_override="" a
155
+ local lang="" topic="" color="" api="" endpoint="" rotate="6" count="15" compose="auto" yes="0" base_override="" a
156
156
  while [ $# -gt 0 ]; do
157
157
  case "$1" in
158
158
  --lang) lang="$2"; shift 2;; --topic) topic="$2"; shift 2;;
@@ -189,8 +189,16 @@ cmd_init() {
189
189
  sports "Sports" science "Science" health "Health" entertainment "Entertainment"
190
190
  topic="$CHOICE"
191
191
  fi
192
+ local cur_color; cur_color=$(cfg_get color)
193
+ echo "Select headline color (change anytime: newsline color):" >&2
194
+ choose "${cur_color:-white}" \
195
+ default "Terminal default (gray)" white "White" cyan "Cyan" yellow "Yellow" \
196
+ green "Green" blue "Blue" magenta "Magenta" red "Red"
197
+ color="$CHOICE"
192
198
  else
199
+ # --yes: keep a color previously set via init/`newsline color`; white on first run
193
200
  lang="${lang:-$detected}"; topic="${topic:-general}"
201
+ color=$(cfg_get color); [ -n "$color" ] || color="white"
194
202
  fi
195
203
 
196
204
  # Always KEEP an existing status line and show newsline below it (no prompt).
@@ -210,13 +218,14 @@ cmd_init() {
210
218
  fi
211
219
 
212
220
  mkdir -p "$CONFIG_DIR"
213
- python3 - "$CONFIG" "$lang" "$topic" "$rotate" "$count" "$api" "$endpoint" "$base" "$base_obj" <<'PY' || { echo "✗ could not write $CONFIG" >&2; return 1; }
221
+ python3 - "$CONFIG" "$lang" "$topic" "$rotate" "$count" "$api" "$endpoint" "$base" "$base_obj" "$color" <<'PY' || { echo "✗ could not write $CONFIG" >&2; return 1; }
214
222
  import json,os,sys
215
- _,path,lang,topic,rotate,count,api,endpoint,base,base_obj=sys.argv
223
+ _,path,lang,topic,rotate,count,api,endpoint,base,base_obj,color=sys.argv
216
224
  try:
217
225
  d={"lang":lang,"topic":topic,"rotate":int(rotate),"count":int(count)}
218
226
  except ValueError:
219
227
  sys.stderr.write("newsline: --rotate/--count must be integers\n"); sys.exit(3)
228
+ if color and color not in ("default","none","off"): d["color"]=color
220
229
  if api: d["api"]=api
221
230
  if endpoint: d["endpoint"]=endpoint
222
231
  if base: d["base_statusline"]=base
@@ -257,6 +266,32 @@ PY
257
266
  echo " It appears on your next message to Claude — no restart needed."
258
267
  }
259
268
 
269
+ cmd_color() { # newsline color — each run steps to the next color (wraps around)
270
+ local cur new; cur=$(cfg_get color)
271
+ new=$(python3 - "${cur:-default}" <<'PY'
272
+ import sys
273
+ p=["default","white","cyan","yellow","green","blue","magenta","red"]
274
+ c=sys.argv[1]
275
+ print(p[(p.index(c)+1)%len(p)] if c in p else "default")
276
+ PY
277
+ )
278
+ mkdir -p "$CONFIG_DIR"
279
+ python3 - "$CONFIG" "$new" <<'PY' || { echo "✗ could not write $CONFIG" >&2; return 1; }
280
+ import json,os,sys
281
+ path,color=sys.argv[1],sys.argv[2]
282
+ try: d=json.load(open(path))
283
+ except Exception: d={}
284
+ if color in ("default","none","off"): d.pop("color",None)
285
+ else: d["color"]=color
286
+ tmp=path+".tmp"
287
+ with open(tmp,"w") as f: json.dump(d,f,indent=2,ensure_ascii=False)
288
+ os.replace(tmp,path)
289
+ PY
290
+ echo "✔ headline color: $new — preview:"
291
+ load_config
292
+ "$HERE/statusline.sh"; echo
293
+ }
294
+
260
295
  cmd_uninstall() {
261
296
  local base base_obj
262
297
  base=$(cfg_get base_statusline)
@@ -299,7 +334,11 @@ PY
299
334
  usage() {
300
335
  cat <<'EOF'
301
336
  newsline — local news status-line utility
302
- newsline init [--lang ko] [--topic tech] set up & wire the status line
337
+ newsline init [--lang ko] [--topic tech] set up & wire the status line
338
+ (asks language / topic / color)
339
+ newsline color next headline color: default(gray) → white
340
+ → cyan → yellow → green → blue → magenta
341
+ → red → back to default
303
342
  newsline uninstall remove & restore previous status line
304
343
  EOF
305
344
  if [ "${1:-}" = "--all" ]; then
@@ -318,6 +357,7 @@ case "${1:-help}" in
318
357
  refresh) shift; cmd_refresh "$@";;
319
358
  once) shift; cmd_once "$@";;
320
359
  init) shift; cmd_init "$@";;
360
+ color) shift; cmd_color;;
321
361
  uninstall) shift; cmd_uninstall "$@";;
322
362
  help|-h|--help) shift; usage "$@";;
323
363
  *) usage; exit 1;;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newsline-cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Locale-aware one-line news in your Claude Code status line — local, composes with your existing status line.",
5
5
  "bin": {
6
6
  "newsline": "newsline"
package/readme/de.md CHANGED
@@ -31,7 +31,7 @@ npm i -g newsline-cli && newsline init
31
31
  ```
32
32
 
33
33
  Die News-Zeile erscheint bei deiner **nächsten Nachricht** – kein Neustart nötig. Die Einrichtung fragt
34
- nach Sprache und Thema und behält deine bestehende Statusleiste bei.
34
+ nach Sprache, Thema und Schlagzeilenfarbe und behält deine bestehende Statusleiste bei.
35
35
 
36
36
  ## Was es macht
37
37
 
@@ -73,6 +73,11 @@ Führe `newsline init` erneut aus oder bearbeite `~/.config/newsline/config.json
73
73
  | `count` | `15` | Schlagzeilen im Wechsel |
74
74
  | `maxlen` | `120` | maximale Zeichen (`max` = kein Abschneiden) |
75
75
  | `icon` | `📰` | vorangestelltes Symbol (`none` zum Ausblenden) |
76
+ | `color` | `white` | Farbe der Schlagzeile: `default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
77
+
78
+ Oder `newsline color` verwenden — jeder Aufruf wechselt zur nächsten Farbe (default(gray) →
79
+ white → cyan → yellow → green → blue → magenta → red), sichtbar beim nächsten
80
+ Statuszeilen-Refresh.
76
81
 
77
82
  ## Deinstallieren
78
83
 
package/readme/es.md CHANGED
@@ -30,7 +30,7 @@ npm i -g newsline-cli && newsline init
30
30
  ```
31
31
 
32
32
  La línea de noticias aparece en tu **próximo mensaje**, sin reiniciar. La configuración te pregunta el
33
- idioma y el tema, y conserva tu barra de estado actual.
33
+ idioma, el tema y el color del titular, y conserva tu barra de estado actual.
34
34
 
35
35
  ## Qué hace
36
36
 
@@ -72,6 +72,11 @@ Vuelve a ejecutar `newsline init` o edita `~/.config/newsline/config.json`:
72
72
  | `count` | `15` | titulares en rotación |
73
73
  | `maxlen` | `120` | caracteres máximos (`max` = sin recorte) |
74
74
  | `icon` | `📰` | icono inicial (`none` para ocultarlo) |
75
+ | `color` | `white` | color del titular: `default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
76
+
77
+ O usa `newsline color` — cada ejecución pasa al siguiente color (default(gray) → white →
78
+ cyan → yellow → green → blue → magenta → red), visible en el próximo refresco de la
79
+ línea de estado.
75
80
 
76
81
  ## Desinstalar
77
82
 
package/readme/fr.md CHANGED
@@ -30,7 +30,7 @@ npm i -g newsline-cli && newsline init
30
30
  ```
31
31
 
32
32
  La ligne d'actualité apparaît dès votre **prochain message** — sans redémarrage. La configuration vous
33
- demande une langue et un thème, et conserve votre barre d'état existante.
33
+ demande une langue, un thème et une couleur de titre, et conserve votre barre d'état existante.
34
34
 
35
35
  ## Ce que ça fait
36
36
 
@@ -73,6 +73,11 @@ Relancez `newsline init`, ou modifiez `~/.config/newsline/config.json` :
73
73
  | `count` | `15` | titres en rotation |
74
74
  | `maxlen` | `120` | caractères maximum (`max` = sans coupure) |
75
75
  | `icon` | `📰` | icône de tête (`none` pour masquer) |
76
+ | `color` | `white` | couleur du titre : `default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
77
+
78
+ Ou utilisez `newsline color` — chaque exécution passe à la couleur suivante (default(gray) →
79
+ white → cyan → yellow → green → blue → magenta → red), visible au prochain
80
+ rafraîchissement de la ligne d'état.
76
81
 
77
82
  ## Désinstaller
78
83
 
package/readme/ja.md CHANGED
@@ -29,7 +29,7 @@ npm i -g newsline-cli && newsline init
29
29
  /plugin install newsline@itdar
30
30
  ```
31
31
 
32
- ニュース行は **次のメッセージ** で表示されます — 再起動は不要です。セットアップで言語とトピックを
32
+ ニュース行は **次のメッセージ** で表示されます — 再起動は不要です。セットアップで言語・トピック・文字色を
33
33
  尋ね、既存のステータスラインはそのまま保持します。
34
34
 
35
35
  ## 何をするか
@@ -71,6 +71,10 @@ npm i -g newsline-cli && newsline init
71
71
  | `count` | `15` | 切り替えるヘッドライン数 |
72
72
  | `maxlen` | `120` | 最大文字数(`max` = 無制限) |
73
73
  | `icon` | `📰` | 先頭アイコン(`none` で非表示) |
74
+ | `color` | `white` | 見出しの文字色:`default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
75
+
76
+ `newsline color` を実行するたびに次の色へ進みます(default(gray) → white → cyan → yellow →
77
+ green → blue → magenta → red の順で循環、次のステータスライン更新で反映)。
74
78
 
75
79
  ## アンインストール
76
80
 
package/readme/ko.md CHANGED
@@ -29,7 +29,7 @@ npm i -g newsline-cli && newsline init
29
29
  /plugin install newsline@itdar
30
30
  ```
31
31
 
32
- 뉴스 줄은 **다음 메시지 때** 나타납니다 — 재시작 불필요. 셋업은 언어·분야를 물어보고, 기존
32
+ 뉴스 줄은 **다음 메시지 때** 나타납니다 — 재시작 불필요. 셋업은 언어·분야·글자 색을 물어보고, 기존
33
33
  상태줄은 유지합니다.
34
34
 
35
35
  ## 무엇을 하나
@@ -67,6 +67,10 @@ npm i -g newsline-cli && newsline init
67
67
  | `count` | `15` | 회전 헤드라인 수 |
68
68
  | `maxlen` | `120` | 최대 글자수 (`max`=무제한) |
69
69
  | `icon` | `📰` | 앞 아이콘 (`none`이면 제거) |
70
+ | `color` | `white` | 뉴스 글자 색: `default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
71
+
72
+ `newsline color`를 실행할 때마다 다음 색으로 넘어갑니다 (default(gray) → white → cyan →
73
+ yellow → green → blue → magenta → red 순환, 다음 상태줄 갱신 때 반영).
70
74
 
71
75
  ## 제거
72
76
 
package/readme/pt.md CHANGED
@@ -30,7 +30,7 @@ npm i -g newsline-cli && newsline init
30
30
  ```
31
31
 
32
32
  A linha de notícias aparece na sua **próxima mensagem** — sem reiniciar. A configuração pergunta o
33
- idioma e o tema, e mantém a sua barra de status atual.
33
+ idioma, o tema e a cor da manchete, e mantém a sua barra de status atual.
34
34
 
35
35
  ## O que faz
36
36
 
@@ -71,6 +71,11 @@ Execute `newsline init` novamente ou edite `~/.config/newsline/config.json`:
71
71
  | `count` | `15` | manchetes na rotação |
72
72
  | `maxlen` | `120` | máximo de caracteres (`max` = sem corte) |
73
73
  | `icon` | `📰` | ícone inicial (`none` para ocultar) |
74
+ | `color` | `white` | cor da manchete: `default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
75
+
76
+ Ou use `newsline color` — cada execução avança para a próxima cor (default(gray) → white →
77
+ cyan → yellow → green → blue → magenta → red), visível no próximo refresh da linha
78
+ de status.
74
79
 
75
80
  ## Desinstalar
76
81
 
package/readme/zh.md CHANGED
@@ -29,7 +29,7 @@ npm i -g newsline-cli && newsline init
29
29
  /plugin install newsline@itdar
30
30
  ```
31
31
 
32
- 新闻行会在你的 **下一条消息** 时出现——无需重启。设置会询问语言和主题,并保留你现有的状态栏。
32
+ 新闻行会在你的 **下一条消息** 时出现——无需重启。设置会询问语言、主题和文字颜色,并保留你现有的状态栏。
33
33
 
34
34
  ## 它做什么
35
35
 
@@ -65,6 +65,10 @@ npm i -g newsline-cli && newsline init
65
65
  | `count` | `15` | 轮播头条数量 |
66
66
  | `maxlen` | `120` | 最大字符数(`max` = 不截断) |
67
67
  | `icon` | `📰` | 前置图标(`none` 为隐藏) |
68
+ | `color` | `white` | 新闻文字颜色:`default` `white` `cyan` `yellow` `green` `blue` `magenta` `red` |
69
+
70
+ 也可以运行 `newsline color` — 每次执行切换到下一种颜色(default(gray) → white → cyan →
71
+ yellow → green → blue → magenta → red,下次状态栏刷新即生效)。
68
72
 
69
73
  ## 卸载
70
74
 
package/refresh.sh CHANGED
@@ -23,7 +23,7 @@ case "$API" in off|OFF|none|local) API="" ;; esac
23
23
  COUNT="${NEWSLINE_COUNT:-15}" # how many headlines to cache for rotation
24
24
  # Client version, sent to /feed as ?v= for the server-side update nudge.
25
25
  # Bump together with package.json when tagging a release.
26
- export NEWSLINE_VERSION="${NEWSLINE_VERSION:-0.1.6}"
26
+ export NEWSLINE_VERSION="${NEWSLINE_VERSION:-0.1.8}"
27
27
  LOCK="$CACHE_DIR/refresh.lock"
28
28
  mkdir -p "$CACHE_DIR" 2>/dev/null
29
29
 
package/statusline.sh CHANGED
@@ -24,6 +24,24 @@ if [ "$needs_refresh" = "1" ]; then
24
24
  ( "$HERE/refresh.sh" >/dev/null 2>&1 & ) 2>/dev/null
25
25
  fi
26
26
 
27
+ # --- optional headline color (NEWSLINE_COLOR: a name, or raw SGR params) ---
28
+ # Applied at PRINT time, not baked into the cache, so `newsline color` shows up
29
+ # on the next status-line tick without waiting for a refresh.
30
+ SGR=""
31
+ case "$(printf '%s' "${NEWSLINE_COLOR:-}" | tr '[:upper:]' '[:lower:]')" in
32
+ ''|default|none|off) SGR="" ;;
33
+ dim) SGR="2" ;;
34
+ gray|grey) SGR="90" ;;
35
+ red) SGR="31" ;; green) SGR="32" ;; yellow) SGR="33" ;;
36
+ blue) SGR="34" ;; magenta) SGR="35" ;; cyan) SGR="36" ;;
37
+ white) SGR="37" ;; orange) SGR="38;5;208" ;;
38
+ *[!0-9\;]*) SGR="" ;; # unknown name — ignore, print plain
39
+ *) SGR="${NEWSLINE_COLOR}" ;; # raw SGR params, e.g. "38;5;245"
40
+ esac
41
+ colorize() { # wrap text in the configured color (no-op when unset); no newline
42
+ if [ -n "$SGR" ]; then printf '\033[%sm%s\033[0m' "$SGR" "$1"; else printf '%s' "$1"; fi
43
+ }
44
+
27
45
  # --- print one headline, rotating across the cached set by wall-clock time ---
28
46
  # The cache holds N headlines (one per line). We show a different one every
29
47
  # NEWSLINE_ROTATE seconds — a ticker feel with zero stored state.
@@ -35,12 +53,12 @@ if [ -s "$CACHE_FILE" ]; then
35
53
  [ "$rot" -ge 1 ] || rot=6 # 0 would divide by zero below
36
54
  now="${NEWSLINE_NOW:-$(date +%s)}" # NEWSLINE_NOW overrides clock (tests/debug)
37
55
  idx=$(( (now / rot) % n + 1 ))
38
- sed -n "${idx}p" "$CACHE_FILE"
56
+ colorize "$(sed -n "${idx}p" "$CACHE_FILE")"; printf '\n'
39
57
  else
40
- printf '📰 …'
58
+ colorize '📰 …'
41
59
  fi
42
60
  else
43
- printf '📰 …' # first run, before the first refresh lands
61
+ colorize '📰 …' # first run, before the first refresh lands
44
62
  fi
45
63
 
46
64
  # --- server-driven update nudge (written/cleared by refresh.sh), below the news ---