salt-api-cli 1.4.0__tar.gz → 1.4.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salt-api-cli
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: CLI to access salt-api
5
5
  Author-email: Pradish Bijukchhe <pradish@sandbox.com.np>
6
6
  License-Expression: MIT
@@ -169,12 +169,7 @@ def _print_state_return(minion: str, states: dict[str, Any]) -> None:
169
169
  """Render one minion's state run: header, a table of states, summary."""
170
170
  ordered = sorted(states.items(), key=lambda kv: kv[1].get("__run_num__", 1 << 30))
171
171
 
172
- table = Table(box=None, show_header=False, pad_edge=False)
173
- table.add_column("marker", no_wrap=True)
174
- table.add_column("function", style="cyan", no_wrap=True)
175
- table.add_column("ref", style="dim", no_wrap=True)
176
- table.add_column("detail", no_wrap=True, overflow="ellipsis")
177
-
172
+ rows: list[tuple[Text, str, str, str | Text]] = []
178
173
  for key, state in ordered:
179
174
  status = _state_status(state)
180
175
  marker, style = _STATUS_STYLE[status]
@@ -188,7 +183,28 @@ def _print_state_return(minion: str, states: dict[str, Any]) -> None:
188
183
  detail = Text(_short(state.get("comment", ""), 240), style="red")
189
184
  else: # diff / skip
190
185
  detail = _short(state.get("comment", ""))
191
- table.add_row(Text(marker, style=style), _state_function(key), ref, detail)
186
+ rows.append((Text(marker, style=style), _state_function(key), ref, detail))
187
+
188
+ # Pin the detail column to whatever width is left so rich shrinks *it*
189
+ # (ellipsis) rather than collapsing the short marker/function/ref columns
190
+ # to nothing on a narrow terminal. Width budget: 2-space left Padding +
191
+ # 1-char marker + the natural function/ref widths + three 2-space column
192
+ # gaps (pad_edge=False). Floor at 20 so detail never vanishes outright.
193
+ fn_w = max((len(fn) for _, fn, _, _ in rows), default=8)
194
+ ref_w = max((len(ref) for _, _, ref, _ in rows), default=8)
195
+ nat_w = max(
196
+ (len(d.plain if isinstance(d, Text) else d) for _, _, _, d in rows), default=0
197
+ )
198
+ detail_w = min(nat_w, max(20, console.width - 2 - 1 - fn_w - ref_w - 3 * 2))
199
+
200
+ table = Table(box=None, show_header=False, pad_edge=False)
201
+ table.add_column("marker", no_wrap=True)
202
+ table.add_column("function", style="cyan", no_wrap=True)
203
+ table.add_column("ref", style="dim", no_wrap=True)
204
+ table.add_column("detail", no_wrap=True, overflow="ellipsis", width=detail_w)
205
+
206
+ for row in rows:
207
+ table.add_row(*row)
192
208
 
193
209
  counts, total_ms = _count_states(states)
194
210
  console.print(Text(minion, style="bold"))
@@ -404,8 +420,14 @@ def _stream_job(
404
420
  info: Any = _first_return(submit)
405
421
  jid = info.get("jid")
406
422
  if not jid:
407
- # No job id: nothing matched, or salt-api answered with an error body.
408
- console.print_json(json.dumps(submit))
423
+ # No job id: either nothing matched (salt-api hands back an empty
424
+ # body, e.g. {"return": [{}]}) or it answered with an error body. An
425
+ # empty info means no minions matched — say so plainly; reserve the
426
+ # raw JSON dump for an actual error worth showing verbatim.
427
+ if not info:
428
+ console.print("(no minions matched the target)")
429
+ else:
430
+ console.print_json(json.dumps(submit))
409
431
  return None
410
432
 
411
433
  targeted = sorted(info.get("minions") or [], key=_natural_key)
@@ -0,0 +1 @@
1
+ __version__ = "1.4.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salt-api-cli
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: CLI to access salt-api
5
5
  Author-email: Pradish Bijukchhe <pradish@sandbox.com.np>
6
6
  License-Expression: MIT
@@ -1 +0,0 @@
1
- __version__ = "1.4.0"
File without changes
File without changes
File without changes