salt-api-cli 1.4.4__tar.gz → 1.4.5__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.4
3
+ Version: 1.4.5
4
4
  Summary: CLI to access salt-api
5
5
  Author-email: Pradish Bijukchhe <pradish@sandbox.com.np>
6
6
  License-Expression: MIT
@@ -100,10 +100,13 @@ def _state_function(key: str) -> str:
100
100
  return parts[0]
101
101
 
102
102
 
103
- def _short(text: str, limit: int = 100) -> str:
104
- """Collapse whitespace and truncate a comment to one tidy line."""
105
- flat = " ".join(str(text).split())
106
- return flat if len(flat) <= limit else flat[: limit - 3] + "..."
103
+ def _oneline(text: str) -> str:
104
+ """Collapse all whitespace runs to single spaces, on one line.
105
+
106
+ Used for compact details (e.g. the list of changed keys) where the
107
+ structure doesn't matter. Nothing is truncated — long values are folded
108
+ across lines by the table's detail column, never cut off."""
109
+ return " ".join(str(text).split())
107
110
 
108
111
 
109
112
  def _fmt_duration(ms: float) -> str:
@@ -185,26 +188,23 @@ def _print_state_return(minion: str, states: dict[str, Any]) -> None:
185
188
  str(changes.get("stdout") or "").strip()
186
189
  or str(changes.get("stderr") or "").strip()
187
190
  )
188
- # Full output, folded across lines, so nothing is cut off.
189
- detail = (
190
- Text(out, no_wrap=False, overflow="fold")
191
- if out
192
- else "changed: (no output)"
193
- )
191
+ detail = Text(out) if out else "changed: (no output)"
194
192
  else:
195
193
  changed = ", ".join(changes) or "(changes)"
196
- detail = f"changed: {_short(changed)}"
194
+ detail = f"changed: {_oneline(changed)}"
197
195
  elif status == "fail":
198
- detail = Text(_short(state.get("comment", ""), 240), style="red")
196
+ detail = Text(str(state.get("comment", "")).strip(), style="red")
199
197
  else: # diff / skip
200
- detail = _short(state.get("comment", ""))
198
+ detail = Text(str(state.get("comment", "")).strip())
201
199
  rows.append((Text(marker, style=style), _state_function(key), ref, detail))
202
200
 
203
- # Pin the detail column to whatever width is left so rich shrinks *it*
204
- # (ellipsis) rather than collapsing the short marker/function/ref columns
205
- # to nothing on a narrow terminal. Width budget: 2-space left Padding +
206
- # 1-char marker + the natural function/ref widths + three 2-space column
207
- # gaps (pad_edge=False). Floor at 20 so detail never vanishes outright.
201
+ # Pin the detail column to whatever width is left so rich folds *it*
202
+ # (wraps onto extra lines) rather than collapsing the short
203
+ # marker/function/ref columns to nothing on a narrow terminal. Full
204
+ # content is always shown long details just span more rows. Width
205
+ # budget: 2-space left Padding + 1-char marker + the natural function/ref
206
+ # widths + three 2-space column gaps (pad_edge=False). Floor at 20 so
207
+ # detail never gets squeezed to a sliver.
208
208
  fn_w = max((len(fn) for _, fn, _, _ in rows), default=8)
209
209
  ref_w = max((len(ref) for _, _, ref, _ in rows), default=8)
210
210
  nat_w = max(
@@ -221,7 +221,7 @@ def _print_state_return(minion: str, states: dict[str, Any]) -> None:
221
221
  table.add_column("marker", no_wrap=True)
222
222
  table.add_column("function", style="cyan", no_wrap=True)
223
223
  table.add_column("ref", style="dim", no_wrap=True)
224
- table.add_column("detail", no_wrap=True, overflow="ellipsis", width=detail_w)
224
+ table.add_column("detail", overflow="fold", width=detail_w)
225
225
 
226
226
  for row in rows:
227
227
  table.add_row(*row)
@@ -741,11 +741,23 @@ def run_keys(args: argparse.Namespace, call: Callable[..., dict[str, Any]]) -> N
741
741
  "delete": "key.delete",
742
742
  }
743
743
  match: str = "*" if action == "accept-all" else args.match
744
+
745
+ # salt's key.delete returns an empty payload on success: it evaluates the
746
+ # name match *after* removing the key files, so nothing matches and the
747
+ # `return` comes back `{}` even when keys were deleted (accept/reject don't
748
+ # hit this — their keys still exist when the return is built). Resolve the
749
+ # affected ids up front so we can report what was actually deleted instead
750
+ # of misprinting "(no keys changed)".
751
+ pre_match: dict[str, list[str]] = {}
752
+ if action == "delete":
753
+ nm = call(fun="key.name_match", match=match)
754
+ pre_match = nm["return"][0]["data"].get("return", {}) or {}
755
+
744
756
  result = call(fun=fun_map[action], match=match)
745
757
  data = result["return"][0]["data"]
746
758
  if not data.get("success"):
747
759
  sys.exit(f"failed: {data}")
748
- changed: dict[str, list[str]] = data.get("return", {})
760
+ changed: dict[str, list[str]] = data.get("return", {}) or pre_match
749
761
  if not changed:
750
762
  console.print("(no keys changed)")
751
763
  return
@@ -0,0 +1 @@
1
+ __version__ = "1.4.5"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salt-api-cli
3
- Version: 1.4.4
3
+ Version: 1.4.5
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.4"
File without changes
File without changes
File without changes