catocli 3.0.13__py3-none-any.whl → 3.0.14__py3-none-any.whl
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.
Potentially problematic release.
This version of catocli might be problematic. Click here for more details.
- catocli/Utils/help_formatter.py +76 -8
- catocli/__init__.py +1 -1
- {catocli-3.0.13.dist-info → catocli-3.0.14.dist-info}/METADATA +1 -1
- {catocli-3.0.13.dist-info → catocli-3.0.14.dist-info}/RECORD +8 -8
- {catocli-3.0.13.dist-info → catocli-3.0.14.dist-info}/WHEEL +0 -0
- {catocli-3.0.13.dist-info → catocli-3.0.14.dist-info}/entry_points.txt +0 -0
- {catocli-3.0.13.dist-info → catocli-3.0.14.dist-info}/licenses/LICENSE +0 -0
- {catocli-3.0.13.dist-info → catocli-3.0.14.dist-info}/top_level.txt +0 -0
catocli/Utils/help_formatter.py
CHANGED
|
@@ -94,15 +94,16 @@ class JSONExample:
|
|
|
94
94
|
return [self.command_template.format(command=command_name, json=self.json_data)]
|
|
95
95
|
|
|
96
96
|
def _format_powershell_comprehensive(self, command_name: str) -> List[str]:
|
|
97
|
-
"""Format PowerShell here-string example with
|
|
98
|
-
#
|
|
97
|
+
"""Format PowerShell here-string example with proper quote escaping"""
|
|
98
|
+
# Escape double quotes in JSON for PowerShell compatibility
|
|
99
99
|
escaped_json = self.json_data.replace('"', '\\"')
|
|
100
100
|
|
|
101
|
+
# Use here-string format which handles quotes better in PowerShell
|
|
101
102
|
examples = [
|
|
102
|
-
"# PowerShell:",
|
|
103
|
+
"# PowerShell (using here-string):",
|
|
103
104
|
f"catocli {command_name} @'",
|
|
104
105
|
escaped_json,
|
|
105
|
-
"'@"
|
|
106
|
+
"'@ -p"
|
|
106
107
|
]
|
|
107
108
|
|
|
108
109
|
return examples
|
|
@@ -228,8 +229,35 @@ class UniversalHelpFormatter:
|
|
|
228
229
|
for example in readme_examples:
|
|
229
230
|
# Check if this example starts with a comment (lines starting with #)
|
|
230
231
|
if example.startswith('#') and '\n' in example:
|
|
231
|
-
# This is a comment followed by a command -
|
|
232
|
-
|
|
232
|
+
# This is a comment followed by a command - need to format the command part
|
|
233
|
+
lines = example.split('\n', 1)
|
|
234
|
+
if len(lines) == 2:
|
|
235
|
+
comment_line = lines[0]
|
|
236
|
+
command_line = lines[1]
|
|
237
|
+
|
|
238
|
+
# Check if command has JSON and format appropriately
|
|
239
|
+
if '{' in command_line and '}' in command_line:
|
|
240
|
+
json_match = self._extract_json_from_example(command_line)
|
|
241
|
+
if json_match:
|
|
242
|
+
# Create JSONExample and apply platform-specific formatting
|
|
243
|
+
json_example = JSONExample(json_match)
|
|
244
|
+
formatted_commands = json_example.format_for_platform(self.platform_info, command_name)
|
|
245
|
+
# Add comment first, then formatted commands
|
|
246
|
+
help_lines.append(comment_line)
|
|
247
|
+
help_lines.extend(formatted_commands)
|
|
248
|
+
else:
|
|
249
|
+
# JSON extraction failed, format as simple command
|
|
250
|
+
formatted_command = self._format_simple_command_for_platform(command_line)
|
|
251
|
+
help_lines.append(comment_line)
|
|
252
|
+
help_lines.append(formatted_command)
|
|
253
|
+
else:
|
|
254
|
+
# Simple command - apply platform formatting
|
|
255
|
+
formatted_command = self._format_simple_command_for_platform(command_line)
|
|
256
|
+
help_lines.append(comment_line)
|
|
257
|
+
help_lines.append(formatted_command)
|
|
258
|
+
else:
|
|
259
|
+
# Fallback - preserve as-is
|
|
260
|
+
help_lines.append(example)
|
|
233
261
|
elif '{' in example and '}' in example:
|
|
234
262
|
# Check if this is a multi-line JSON example that can be platform-formatted
|
|
235
263
|
json_match = self._extract_json_from_example(example)
|
|
@@ -242,8 +270,9 @@ class UniversalHelpFormatter:
|
|
|
242
270
|
# Preserve as-is if it has comments or JSON extraction fails
|
|
243
271
|
help_lines.append(example)
|
|
244
272
|
else:
|
|
245
|
-
# Simple command examples without JSON
|
|
246
|
-
|
|
273
|
+
# Simple command examples without JSON - apply platform formatting
|
|
274
|
+
formatted_example = self._format_simple_command_for_platform(example)
|
|
275
|
+
help_lines.append(formatted_example)
|
|
247
276
|
help_lines.append("") # Add spacing between examples
|
|
248
277
|
|
|
249
278
|
description_examples = []
|
|
@@ -394,6 +423,45 @@ class UniversalHelpFormatter:
|
|
|
394
423
|
|
|
395
424
|
return unique_examples
|
|
396
425
|
|
|
426
|
+
def _format_simple_command_for_platform(self, example: str) -> str:
|
|
427
|
+
"""Format a simple command example for the current platform"""
|
|
428
|
+
# If it's already a comment or doesn't contain catocli command, return as-is
|
|
429
|
+
if example.startswith('#') or 'catocli' not in example:
|
|
430
|
+
return example
|
|
431
|
+
|
|
432
|
+
# For Windows, we need to adjust command syntax
|
|
433
|
+
if self.platform_info.platform == 'windows':
|
|
434
|
+
if self.platform_info.shell == 'powershell':
|
|
435
|
+
# PowerShell-specific adjustments
|
|
436
|
+
# Convert Unix-style command substitution to PowerShell equivalent
|
|
437
|
+
if '$(cat' in example:
|
|
438
|
+
# Handle different $(cat) variations
|
|
439
|
+
import re
|
|
440
|
+
# Pattern for $(cat file.json) or $(cat < file.json)
|
|
441
|
+
cat_pattern = r'\$\(cat\s*<?\s*([^\)]+)\)'
|
|
442
|
+
def replace_cat(match):
|
|
443
|
+
filename = match.group(1).strip()
|
|
444
|
+
return f'(Get-Content {filename} -Raw)'
|
|
445
|
+
example = re.sub(cat_pattern, replace_cat, example)
|
|
446
|
+
# Handle quotes - PowerShell prefers double quotes for JSON strings
|
|
447
|
+
# But for simple parameter examples, keep single quotes for strings
|
|
448
|
+
return example
|
|
449
|
+
elif self.platform_info.shell == 'cmd':
|
|
450
|
+
# CMD-specific adjustments - CMD has many limitations
|
|
451
|
+
if '$(cat ' in example:
|
|
452
|
+
return "# CMD: Save JSON to file first, then use the file path"
|
|
453
|
+
elif len(example) > 100:
|
|
454
|
+
return "# CMD: Use PowerShell for complex commands - CMD has line length limits"
|
|
455
|
+
# For CMD, convert single quotes to double quotes for JSON
|
|
456
|
+
if "'{" in example and "}'" in example:
|
|
457
|
+
example = example.replace("'{", '"{')
|
|
458
|
+
example = example.replace("}'", '}"')
|
|
459
|
+
# Escape internal double quotes
|
|
460
|
+
# This is complex, so provide a simplification
|
|
461
|
+
return "# CMD: " + example + " (escape internal quotes as needed)"
|
|
462
|
+
|
|
463
|
+
return example
|
|
464
|
+
|
|
397
465
|
def _extract_json_from_example(self, example: str) -> str:
|
|
398
466
|
"""Extract JSON data from a catocli command example"""
|
|
399
467
|
try:
|
catocli/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "3.0.
|
|
1
|
+
__version__ = "3.0.14"
|
|
2
2
|
__cato_host__ = "https://api.catonetworks.com/api/v1/graphql2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
catocli/__init__.py,sha256=
|
|
1
|
+
catocli/__init__.py,sha256=Vbz0AqrJJAgTgTKR_I4uCVbqt44Tq79dDuQw-Or4Ek4,85
|
|
2
2
|
catocli/__main__.py,sha256=6Z0ns_k_kUcz1Qtrn1u7UyUnqB-3e85jM_nppOwFsv4,217
|
|
3
3
|
catocli/clisettings.json,sha256=mXjDGxSR0-XVRk6_5mg5QZbaN4hOR2q-63yiUBWA3vU,1023
|
|
4
4
|
catocli/Utils/clidriver.py,sha256=0_MWDcDqbtJ_k4D396WZI6_CG-qEENQ66hAEQi2iVtk,16298
|
|
5
5
|
catocli/Utils/cliutils.py,sha256=TTrAGlJjy9P07rLPGev9Qjx4w0g0KnWYBYcfNY1VIa8,6875
|
|
6
6
|
catocli/Utils/csv_formatter.py,sha256=eNy3HTTPZjABaNtxK9jSzgtRlL908n-x7_DI5qqCB1k,23668
|
|
7
7
|
catocli/Utils/graphql_utils.py,sha256=yUSJ1gE2_LRYTHq46w6vOa84IuU6BXlBMr1gQB2RcGE,63469
|
|
8
|
-
catocli/Utils/help_formatter.py,sha256=
|
|
8
|
+
catocli/Utils/help_formatter.py,sha256=Q3wLXHlaaaU1MhSsy1PgqbWKA5wCHZcdn8ikCaG_soo,31902
|
|
9
9
|
catocli/Utils/profile_manager.py,sha256=a-cIhlhOiFbAEuX5Im0JraalWufkcAZS1NQQ0T4ck8I,7763
|
|
10
10
|
catocli/Utils/version_checker.py,sha256=tCtsCn7xxMIxOm6cWJSA_yPt0j4mNMK4iWSJej0yM6A,6696
|
|
11
11
|
catocli/parsers/customParserApiClient.py,sha256=GdcQ-Th-508ZQYDtvWBJSNV_yuVtINuDhDuzND8W9kY,81982
|
|
@@ -406,7 +406,7 @@ catocli/templates/scim_users.csv,sha256=Fb_C9W2cXf1swnKSNXanWabny87TKcbwxpor5ze3
|
|
|
406
406
|
catocli/templates/scim_users.json,sha256=VRBc2rDRMiIcA6navhnqdnuvLmouKd9ZE7ZrzGb7kfI,582
|
|
407
407
|
catocli/templates/socket_sites.csv,sha256=S5qY7whbydinMwomoAlDghoiFO_xqUKRwNG1xvzl8BI,1212
|
|
408
408
|
catocli/templates/socket_sites.json,sha256=X3NShci5-q3TpVSsaj62u4jFCvQAhxQ7knC-Lui_gOg,19535
|
|
409
|
-
catocli-3.0.
|
|
409
|
+
catocli-3.0.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
410
410
|
graphql_client/__init__.py,sha256=2nxD4YsWoOnALXi5cXbmtIN_i0NL_eyDTQRTxs52mkI,315
|
|
411
411
|
graphql_client/api_client.py,sha256=2Rc1Zo1xH9Jnk1AO68kLSofTShkZwSVF-WkVtczfIc4,5786
|
|
412
412
|
graphql_client/api_client_types.py,sha256=y1oy1qsg8TM_FPxb8m53ED7tBU29WDhtQqzgg247_kI,11754
|
|
@@ -754,8 +754,8 @@ vendor/urllib3/util/timeout.py,sha256=4eT1FVeZZU7h7mYD1Jq2OXNe4fxekdNvhoWUkZusRp
|
|
|
754
754
|
vendor/urllib3/util/url.py,sha256=wHORhp80RAXyTlAIkTqLFzSrkU7J34ZDxX-tN65MBZk,15213
|
|
755
755
|
vendor/urllib3/util/util.py,sha256=j3lbZK1jPyiwD34T8IgJzdWEZVT-4E-0vYIJi9UjeNA,1146
|
|
756
756
|
vendor/urllib3/util/wait.py,sha256=_ph8IrUR3sqPqi0OopQgJUlH4wzkGeM5CiyA7XGGtmI,4423
|
|
757
|
-
catocli-3.0.
|
|
758
|
-
catocli-3.0.
|
|
759
|
-
catocli-3.0.
|
|
760
|
-
catocli-3.0.
|
|
761
|
-
catocli-3.0.
|
|
757
|
+
catocli-3.0.14.dist-info/METADATA,sha256=waevp-G_tR6CzkOI3-1Y-pLWQLG3Y7fdnSgaCMrQm74,3753
|
|
758
|
+
catocli-3.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
759
|
+
catocli-3.0.14.dist-info/entry_points.txt,sha256=p4k9Orre6aWcqVrNmBbckmCs39h-1naMxRo2AjWmWZ4,50
|
|
760
|
+
catocli-3.0.14.dist-info/top_level.txt,sha256=F4qSgcjcW5wR9EFrO8Ud06F7ZQGFr04a9qALNQDyVxU,52
|
|
761
|
+
catocli-3.0.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|