webscout 8.2.6__py3-none-any.whl → 8.2.7__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 webscout might be problematic. Click here for more details.

Files changed (292) hide show
  1. webscout/AIutel.py +97 -87
  2. webscout/version.py +1 -1
  3. {webscout-8.2.6.dist-info → webscout-8.2.7.dist-info}/METADATA +2 -15
  4. webscout-8.2.7.dist-info/RECORD +26 -0
  5. {webscout-8.2.6.dist-info → webscout-8.2.7.dist-info}/WHEEL +1 -1
  6. webscout-8.2.7.dist-info/entry_points.txt +3 -0
  7. webscout-8.2.7.dist-info/top_level.txt +1 -0
  8. webscout/Extra/GitToolkit/__init__.py +0 -10
  9. webscout/Extra/GitToolkit/gitapi/__init__.py +0 -12
  10. webscout/Extra/GitToolkit/gitapi/repository.py +0 -195
  11. webscout/Extra/GitToolkit/gitapi/user.py +0 -96
  12. webscout/Extra/GitToolkit/gitapi/utils.py +0 -62
  13. webscout/Extra/YTToolkit/YTdownloader.py +0 -957
  14. webscout/Extra/YTToolkit/__init__.py +0 -3
  15. webscout/Extra/YTToolkit/transcriber.py +0 -476
  16. webscout/Extra/YTToolkit/ytapi/__init__.py +0 -6
  17. webscout/Extra/YTToolkit/ytapi/channel.py +0 -307
  18. webscout/Extra/YTToolkit/ytapi/errors.py +0 -13
  19. webscout/Extra/YTToolkit/ytapi/extras.py +0 -45
  20. webscout/Extra/YTToolkit/ytapi/https.py +0 -88
  21. webscout/Extra/YTToolkit/ytapi/patterns.py +0 -61
  22. webscout/Extra/YTToolkit/ytapi/playlist.py +0 -59
  23. webscout/Extra/YTToolkit/ytapi/pool.py +0 -8
  24. webscout/Extra/YTToolkit/ytapi/query.py +0 -40
  25. webscout/Extra/YTToolkit/ytapi/stream.py +0 -63
  26. webscout/Extra/YTToolkit/ytapi/utils.py +0 -62
  27. webscout/Extra/YTToolkit/ytapi/video.py +0 -232
  28. webscout/Extra/__init__.py +0 -7
  29. webscout/Extra/autocoder/__init__.py +0 -9
  30. webscout/Extra/autocoder/autocoder.py +0 -910
  31. webscout/Extra/autocoder/autocoder_utiles.py +0 -332
  32. webscout/Extra/gguf.py +0 -684
  33. webscout/Extra/tempmail/__init__.py +0 -28
  34. webscout/Extra/tempmail/async_utils.py +0 -141
  35. webscout/Extra/tempmail/base.py +0 -161
  36. webscout/Extra/tempmail/cli.py +0 -187
  37. webscout/Extra/tempmail/emailnator.py +0 -84
  38. webscout/Extra/tempmail/mail_tm.py +0 -361
  39. webscout/Extra/tempmail/temp_mail_io.py +0 -292
  40. webscout/Extra/weather.py +0 -194
  41. webscout/Extra/weather_ascii.py +0 -76
  42. webscout/Litlogger/__init__.py +0 -67
  43. webscout/Litlogger/core/__init__.py +0 -6
  44. webscout/Litlogger/core/level.py +0 -23
  45. webscout/Litlogger/core/logger.py +0 -165
  46. webscout/Litlogger/handlers/__init__.py +0 -12
  47. webscout/Litlogger/handlers/console.py +0 -33
  48. webscout/Litlogger/handlers/file.py +0 -143
  49. webscout/Litlogger/handlers/network.py +0 -173
  50. webscout/Litlogger/styles/__init__.py +0 -7
  51. webscout/Litlogger/styles/colors.py +0 -249
  52. webscout/Litlogger/styles/formats.py +0 -458
  53. webscout/Litlogger/styles/text.py +0 -87
  54. webscout/Litlogger/utils/__init__.py +0 -6
  55. webscout/Litlogger/utils/detectors.py +0 -153
  56. webscout/Litlogger/utils/formatters.py +0 -200
  57. webscout/Provider/AI21.py +0 -177
  58. webscout/Provider/AISEARCH/DeepFind.py +0 -250
  59. webscout/Provider/AISEARCH/ISou.py +0 -256
  60. webscout/Provider/AISEARCH/Perplexity.py +0 -359
  61. webscout/Provider/AISEARCH/__init__.py +0 -10
  62. webscout/Provider/AISEARCH/felo_search.py +0 -228
  63. webscout/Provider/AISEARCH/genspark_search.py +0 -208
  64. webscout/Provider/AISEARCH/hika_search.py +0 -198
  65. webscout/Provider/AISEARCH/iask_search.py +0 -436
  66. webscout/Provider/AISEARCH/monica_search.py +0 -246
  67. webscout/Provider/AISEARCH/scira_search.py +0 -322
  68. webscout/Provider/AISEARCH/webpilotai_search.py +0 -281
  69. webscout/Provider/Aitopia.py +0 -316
  70. webscout/Provider/AllenAI.py +0 -447
  71. webscout/Provider/Andi.py +0 -228
  72. webscout/Provider/Blackboxai.py +0 -229
  73. webscout/Provider/ChatGPTClone.py +0 -237
  74. webscout/Provider/ChatGPTGratis.py +0 -194
  75. webscout/Provider/ChatSandbox.py +0 -342
  76. webscout/Provider/Cloudflare.py +0 -325
  77. webscout/Provider/Cohere.py +0 -208
  78. webscout/Provider/Deepinfra.py +0 -338
  79. webscout/Provider/ElectronHub.py +0 -773
  80. webscout/Provider/ExaAI.py +0 -261
  81. webscout/Provider/ExaChat.py +0 -358
  82. webscout/Provider/Free2GPT.py +0 -241
  83. webscout/Provider/GPTWeb.py +0 -249
  84. webscout/Provider/Gemini.py +0 -169
  85. webscout/Provider/GithubChat.py +0 -370
  86. webscout/Provider/GizAI.py +0 -285
  87. webscout/Provider/Glider.py +0 -222
  88. webscout/Provider/Groq.py +0 -801
  89. webscout/Provider/HF_space/__init__.py +0 -0
  90. webscout/Provider/HF_space/qwen_qwen2.py +0 -206
  91. webscout/Provider/HeckAI.py +0 -257
  92. webscout/Provider/HuggingFaceChat.py +0 -469
  93. webscout/Provider/Hunyuan.py +0 -283
  94. webscout/Provider/Jadve.py +0 -291
  95. webscout/Provider/Koboldai.py +0 -381
  96. webscout/Provider/LambdaChat.py +0 -411
  97. webscout/Provider/Llama3.py +0 -259
  98. webscout/Provider/MCPCore.py +0 -315
  99. webscout/Provider/Marcus.py +0 -206
  100. webscout/Provider/Nemotron.py +0 -218
  101. webscout/Provider/Netwrck.py +0 -270
  102. webscout/Provider/OLLAMA.py +0 -396
  103. webscout/Provider/OPENAI/__init__.py +0 -28
  104. webscout/Provider/OPENAI/ai4chat.py +0 -286
  105. webscout/Provider/OPENAI/base.py +0 -46
  106. webscout/Provider/OPENAI/c4ai.py +0 -367
  107. webscout/Provider/OPENAI/chatgpt.py +0 -549
  108. webscout/Provider/OPENAI/chatgptclone.py +0 -481
  109. webscout/Provider/OPENAI/deepinfra.py +0 -309
  110. webscout/Provider/OPENAI/e2b.py +0 -1350
  111. webscout/Provider/OPENAI/exaai.py +0 -404
  112. webscout/Provider/OPENAI/exachat.py +0 -437
  113. webscout/Provider/OPENAI/freeaichat.py +0 -352
  114. webscout/Provider/OPENAI/glider.py +0 -316
  115. webscout/Provider/OPENAI/groq.py +0 -354
  116. webscout/Provider/OPENAI/heckai.py +0 -341
  117. webscout/Provider/OPENAI/llmchatco.py +0 -327
  118. webscout/Provider/OPENAI/mcpcore.py +0 -376
  119. webscout/Provider/OPENAI/multichat.py +0 -368
  120. webscout/Provider/OPENAI/netwrck.py +0 -350
  121. webscout/Provider/OPENAI/opkfc.py +0 -488
  122. webscout/Provider/OPENAI/scirachat.py +0 -462
  123. webscout/Provider/OPENAI/sonus.py +0 -294
  124. webscout/Provider/OPENAI/standardinput.py +0 -425
  125. webscout/Provider/OPENAI/textpollinations.py +0 -329
  126. webscout/Provider/OPENAI/toolbaz.py +0 -406
  127. webscout/Provider/OPENAI/typegpt.py +0 -346
  128. webscout/Provider/OPENAI/uncovrAI.py +0 -455
  129. webscout/Provider/OPENAI/utils.py +0 -211
  130. webscout/Provider/OPENAI/venice.py +0 -413
  131. webscout/Provider/OPENAI/wisecat.py +0 -381
  132. webscout/Provider/OPENAI/writecream.py +0 -156
  133. webscout/Provider/OPENAI/x0gpt.py +0 -371
  134. webscout/Provider/OPENAI/yep.py +0 -327
  135. webscout/Provider/OpenGPT.py +0 -209
  136. webscout/Provider/Openai.py +0 -496
  137. webscout/Provider/PI.py +0 -429
  138. webscout/Provider/Perplexitylabs.py +0 -415
  139. webscout/Provider/QwenLM.py +0 -254
  140. webscout/Provider/Reka.py +0 -214
  141. webscout/Provider/StandardInput.py +0 -290
  142. webscout/Provider/TTI/AiForce/__init__.py +0 -22
  143. webscout/Provider/TTI/AiForce/async_aiforce.py +0 -224
  144. webscout/Provider/TTI/AiForce/sync_aiforce.py +0 -245
  145. webscout/Provider/TTI/FreeAIPlayground/__init__.py +0 -9
  146. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +0 -181
  147. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +0 -180
  148. webscout/Provider/TTI/ImgSys/__init__.py +0 -23
  149. webscout/Provider/TTI/ImgSys/async_imgsys.py +0 -202
  150. webscout/Provider/TTI/ImgSys/sync_imgsys.py +0 -195
  151. webscout/Provider/TTI/MagicStudio/__init__.py +0 -2
  152. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +0 -111
  153. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +0 -109
  154. webscout/Provider/TTI/Nexra/__init__.py +0 -22
  155. webscout/Provider/TTI/Nexra/async_nexra.py +0 -286
  156. webscout/Provider/TTI/Nexra/sync_nexra.py +0 -258
  157. webscout/Provider/TTI/PollinationsAI/__init__.py +0 -23
  158. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +0 -311
  159. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +0 -265
  160. webscout/Provider/TTI/__init__.py +0 -12
  161. webscout/Provider/TTI/aiarta/__init__.py +0 -2
  162. webscout/Provider/TTI/aiarta/async_aiarta.py +0 -482
  163. webscout/Provider/TTI/aiarta/sync_aiarta.py +0 -440
  164. webscout/Provider/TTI/artbit/__init__.py +0 -22
  165. webscout/Provider/TTI/artbit/async_artbit.py +0 -155
  166. webscout/Provider/TTI/artbit/sync_artbit.py +0 -148
  167. webscout/Provider/TTI/fastflux/__init__.py +0 -22
  168. webscout/Provider/TTI/fastflux/async_fastflux.py +0 -261
  169. webscout/Provider/TTI/fastflux/sync_fastflux.py +0 -252
  170. webscout/Provider/TTI/huggingface/__init__.py +0 -22
  171. webscout/Provider/TTI/huggingface/async_huggingface.py +0 -199
  172. webscout/Provider/TTI/huggingface/sync_huggingface.py +0 -195
  173. webscout/Provider/TTI/piclumen/__init__.py +0 -23
  174. webscout/Provider/TTI/piclumen/async_piclumen.py +0 -268
  175. webscout/Provider/TTI/piclumen/sync_piclumen.py +0 -233
  176. webscout/Provider/TTI/pixelmuse/__init__.py +0 -4
  177. webscout/Provider/TTI/pixelmuse/async_pixelmuse.py +0 -249
  178. webscout/Provider/TTI/pixelmuse/sync_pixelmuse.py +0 -182
  179. webscout/Provider/TTI/talkai/__init__.py +0 -4
  180. webscout/Provider/TTI/talkai/async_talkai.py +0 -229
  181. webscout/Provider/TTI/talkai/sync_talkai.py +0 -207
  182. webscout/Provider/TTS/__init__.py +0 -8
  183. webscout/Provider/TTS/base.py +0 -159
  184. webscout/Provider/TTS/deepgram.py +0 -156
  185. webscout/Provider/TTS/elevenlabs.py +0 -111
  186. webscout/Provider/TTS/gesserit.py +0 -128
  187. webscout/Provider/TTS/murfai.py +0 -113
  188. webscout/Provider/TTS/parler.py +0 -111
  189. webscout/Provider/TTS/speechma.py +0 -180
  190. webscout/Provider/TTS/streamElements.py +0 -333
  191. webscout/Provider/TTS/utils.py +0 -280
  192. webscout/Provider/TeachAnything.py +0 -233
  193. webscout/Provider/TextPollinationsAI.py +0 -306
  194. webscout/Provider/TwoAI.py +0 -280
  195. webscout/Provider/TypliAI.py +0 -305
  196. webscout/Provider/Venice.py +0 -258
  197. webscout/Provider/VercelAI.py +0 -253
  198. webscout/Provider/WiseCat.py +0 -233
  199. webscout/Provider/WrDoChat.py +0 -370
  200. webscout/Provider/Writecream.py +0 -237
  201. webscout/Provider/WritingMate.py +0 -269
  202. webscout/Provider/Youchat.py +0 -330
  203. webscout/Provider/__init__.py +0 -178
  204. webscout/Provider/ai4chat.py +0 -203
  205. webscout/Provider/aimathgpt.py +0 -189
  206. webscout/Provider/akashgpt.py +0 -335
  207. webscout/Provider/asksteve.py +0 -212
  208. webscout/Provider/bagoodex.py +0 -145
  209. webscout/Provider/cerebras.py +0 -288
  210. webscout/Provider/chatglm.py +0 -215
  211. webscout/Provider/cleeai.py +0 -213
  212. webscout/Provider/copilot.py +0 -425
  213. webscout/Provider/elmo.py +0 -283
  214. webscout/Provider/freeaichat.py +0 -285
  215. webscout/Provider/geminiapi.py +0 -208
  216. webscout/Provider/geminiprorealtime.py +0 -160
  217. webscout/Provider/granite.py +0 -235
  218. webscout/Provider/hermes.py +0 -266
  219. webscout/Provider/julius.py +0 -223
  220. webscout/Provider/koala.py +0 -268
  221. webscout/Provider/learnfastai.py +0 -325
  222. webscout/Provider/llama3mitril.py +0 -215
  223. webscout/Provider/llmchat.py +0 -255
  224. webscout/Provider/llmchatco.py +0 -306
  225. webscout/Provider/meta.py +0 -798
  226. webscout/Provider/multichat.py +0 -364
  227. webscout/Provider/scira_chat.py +0 -297
  228. webscout/Provider/scnet.py +0 -243
  229. webscout/Provider/searchchat.py +0 -292
  230. webscout/Provider/sonus.py +0 -258
  231. webscout/Provider/talkai.py +0 -194
  232. webscout/Provider/toolbaz.py +0 -353
  233. webscout/Provider/turboseek.py +0 -266
  234. webscout/Provider/typefully.py +0 -330
  235. webscout/Provider/typegpt.py +0 -289
  236. webscout/Provider/uncovr.py +0 -368
  237. webscout/Provider/x0gpt.py +0 -299
  238. webscout/Provider/yep.py +0 -389
  239. webscout/litagent/__init__.py +0 -29
  240. webscout/litagent/agent.py +0 -455
  241. webscout/litagent/constants.py +0 -60
  242. webscout/litprinter/__init__.py +0 -59
  243. webscout/scout/__init__.py +0 -8
  244. webscout/scout/core/__init__.py +0 -7
  245. webscout/scout/core/crawler.py +0 -140
  246. webscout/scout/core/scout.py +0 -568
  247. webscout/scout/core/search_result.py +0 -96
  248. webscout/scout/core/text_analyzer.py +0 -63
  249. webscout/scout/core/text_utils.py +0 -277
  250. webscout/scout/core/web_analyzer.py +0 -52
  251. webscout/scout/core.py +0 -881
  252. webscout/scout/element.py +0 -460
  253. webscout/scout/parsers/__init__.py +0 -69
  254. webscout/scout/parsers/html5lib_parser.py +0 -172
  255. webscout/scout/parsers/html_parser.py +0 -236
  256. webscout/scout/parsers/lxml_parser.py +0 -178
  257. webscout/scout/utils.py +0 -37
  258. webscout/swiftcli/__init__.py +0 -95
  259. webscout/swiftcli/core/__init__.py +0 -7
  260. webscout/swiftcli/core/cli.py +0 -297
  261. webscout/swiftcli/core/context.py +0 -104
  262. webscout/swiftcli/core/group.py +0 -241
  263. webscout/swiftcli/decorators/__init__.py +0 -28
  264. webscout/swiftcli/decorators/command.py +0 -221
  265. webscout/swiftcli/decorators/options.py +0 -220
  266. webscout/swiftcli/decorators/output.py +0 -252
  267. webscout/swiftcli/exceptions.py +0 -21
  268. webscout/swiftcli/plugins/__init__.py +0 -9
  269. webscout/swiftcli/plugins/base.py +0 -135
  270. webscout/swiftcli/plugins/manager.py +0 -262
  271. webscout/swiftcli/utils/__init__.py +0 -59
  272. webscout/swiftcli/utils/formatting.py +0 -252
  273. webscout/swiftcli/utils/parsing.py +0 -267
  274. webscout/zeroart/__init__.py +0 -55
  275. webscout/zeroart/base.py +0 -60
  276. webscout/zeroart/effects.py +0 -99
  277. webscout/zeroart/fonts.py +0 -816
  278. webscout-8.2.6.dist-info/RECORD +0 -307
  279. webscout-8.2.6.dist-info/entry_points.txt +0 -3
  280. webscout-8.2.6.dist-info/top_level.txt +0 -2
  281. webstoken/__init__.py +0 -30
  282. webstoken/classifier.py +0 -189
  283. webstoken/keywords.py +0 -216
  284. webstoken/language.py +0 -128
  285. webstoken/ner.py +0 -164
  286. webstoken/normalizer.py +0 -35
  287. webstoken/processor.py +0 -77
  288. webstoken/sentiment.py +0 -206
  289. webstoken/stemmer.py +0 -73
  290. webstoken/tagger.py +0 -60
  291. webstoken/tokenizer.py +0 -158
  292. {webscout-8.2.6.dist-info → webscout-8.2.7.dist-info}/licenses/LICENSE.md +0 -0
@@ -1,221 +0,0 @@
1
- """Command decorators for SwiftCLI."""
2
-
3
- from functools import wraps
4
- from typing import Any, Callable, Dict, List, Optional, Union
5
-
6
- from ..core.context import Context
7
-
8
- def command(
9
- name: str = None,
10
- help: str = None,
11
- aliases: List[str] = None,
12
- hidden: bool = False
13
- ) -> Callable:
14
- """
15
- Decorator to register a new command.
16
-
17
- This decorator marks a function as a CLI command and provides metadata
18
- about how the command should be registered and displayed.
19
-
20
- Args:
21
- name: Command name (defaults to function name)
22
- help: Help text (defaults to function docstring)
23
- aliases: Alternative names for the command
24
- hidden: Whether to hide from help output
25
-
26
- Example:
27
- @command(name="greet", help="Say hello")
28
- def hello(name: str):
29
- print(f"Hello {name}!")
30
-
31
- @command(aliases=["hi", "hey"])
32
- def hello(name: str):
33
- '''Say hello to someone'''
34
- print(f"Hello {name}!")
35
- """
36
- def decorator(f: Callable) -> Callable:
37
- f._command = {
38
- 'name': name or f.__name__,
39
- 'help': help or f.__doc__,
40
- 'aliases': aliases or [],
41
- 'hidden': hidden
42
- }
43
- return f
44
- return decorator
45
-
46
- def group(
47
- name: str = None,
48
- help: str = None,
49
- chain: bool = False,
50
- invoke_without_command: bool = False
51
- ) -> Callable:
52
- """
53
- Decorator to create a command group.
54
-
55
- Command groups can contain subcommands and optionally chain their results.
56
-
57
- Args:
58
- name: Group name (defaults to function name)
59
- help: Help text (defaults to function docstring)
60
- chain: Whether to chain command results
61
- invoke_without_command: Allow group to be invoked without subcommand
62
-
63
- Example:
64
- @group()
65
- def db():
66
- '''Database commands'''
67
- pass
68
-
69
- @db.command()
70
- def migrate():
71
- '''Run database migrations'''
72
- print("Running migrations...")
73
-
74
- @group(chain=True)
75
- def process():
76
- '''Process data'''
77
- pass
78
-
79
- @process.command()
80
- def validate():
81
- '''Validate data'''
82
- return {"valid": True}
83
- """
84
- def decorator(f: Callable) -> Callable:
85
- f._group = {
86
- 'name': name or f.__name__,
87
- 'help': help or f.__doc__,
88
- 'chain': chain,
89
- 'invoke_without_command': invoke_without_command
90
- }
91
- return f
92
- return decorator
93
-
94
- def pass_context(f: Callable) -> Callable:
95
- """
96
- Decorator to pass CLI context to command.
97
-
98
- This decorator injects the current Context object as the first argument
99
- to the decorated command function.
100
-
101
- Example:
102
- @command()
103
- @pass_context
104
- def status(ctx):
105
- '''Show application status'''
106
- print(f"App: {ctx.cli.name}")
107
- print(f"Debug: {ctx.debug}")
108
- """
109
- f._pass_context = True
110
- return f
111
-
112
- def completion(func: Optional[Callable] = None) -> Callable:
113
- """
114
- Decorator to provide shell completion for a command.
115
-
116
- The decorated function should return a list of possible completions
117
- based on the current incomplete value.
118
-
119
- Example:
120
- @command()
121
- @option("--service", type=str)
122
- def restart(service: str):
123
- '''Restart a service'''
124
- print(f"Restarting {service}...")
125
-
126
- @restart.completion()
127
- def complete_service(ctx, incomplete):
128
- services = ["nginx", "apache", "mysql"]
129
- return [s for s in services if s.startswith(incomplete)]
130
- """
131
- def decorator(f: Callable) -> Callable:
132
- @wraps(f)
133
- def wrapper(ctx: Context, incomplete: str) -> List[str]:
134
- try:
135
- return f(ctx, incomplete)
136
- except Exception:
137
- return []
138
- return wrapper
139
-
140
- if func is None:
141
- return decorator
142
- return decorator(func)
143
-
144
- def argument(
145
- name: str,
146
- type: Any = str,
147
- required: bool = True,
148
- help: str = None,
149
- default: Any = None
150
- ) -> Callable:
151
- """
152
- Decorator to add a command argument.
153
-
154
- Arguments are positional parameters that must be provided in order.
155
-
156
- Args:
157
- name: Argument name
158
- type: Expected type
159
- required: Whether argument is required
160
- help: Help text
161
- default: Default value if not required
162
-
163
- Example:
164
- @command()
165
- @argument("name")
166
- @argument("count", type=int, default=1)
167
- def greet(name: str, count: int):
168
- '''Greet someone multiple times'''
169
- for _ in range(count):
170
- print(f"Hello {name}!")
171
- """
172
- def decorator(f: Callable) -> Callable:
173
- if not hasattr(f, '_arguments'):
174
- f._arguments = []
175
-
176
- f._arguments.append({
177
- 'name': name,
178
- 'type': type,
179
- 'required': required,
180
- 'help': help,
181
- 'default': default
182
- })
183
- return f
184
- return decorator
185
-
186
- def flag(
187
- name: str,
188
- help: str = None,
189
- hidden: bool = False
190
- ) -> Callable:
191
- """
192
- Decorator to add a boolean flag option.
193
-
194
- Flags are special options that don't take a value - they're either
195
- present (True) or absent (False).
196
-
197
- Args:
198
- name: Flag name
199
- help: Help text
200
- hidden: Whether to hide from help output
201
-
202
- Example:
203
- @command()
204
- @flag("--verbose", help="Enable verbose output")
205
- def process(verbose: bool):
206
- '''Process data'''
207
- if verbose:
208
- print("Verbose mode enabled")
209
- """
210
- def decorator(f: Callable) -> Callable:
211
- if not hasattr(f, '_options'):
212
- f._options = []
213
-
214
- f._options.append({
215
- 'param_decls': [name],
216
- 'is_flag': True,
217
- 'help': help,
218
- 'hidden': hidden
219
- })
220
- return f
221
- return decorator
@@ -1,220 +0,0 @@
1
- """Option decorators for SwiftCLI."""
2
-
3
- from typing import Any, Callable, Dict, List, Optional, Union
4
-
5
- def option(
6
- *param_decls: str,
7
- type: Any = str,
8
- required: bool = False,
9
- default: Any = None,
10
- help: str = None,
11
- is_flag: bool = False,
12
- multiple: bool = False,
13
- count: bool = False,
14
- prompt: bool = False,
15
- hide_input: bool = False,
16
- confirmation_prompt: bool = False,
17
- prompt_required: bool = True,
18
- show_default: bool = True,
19
- choices: Optional[List[Any]] = None,
20
- case_sensitive: bool = True,
21
- callback: Optional[Callable] = None,
22
- hidden: bool = False
23
- ) -> Callable:
24
- """
25
- Decorator to add an option to a command.
26
-
27
- Options are named parameters that can be provided in any order.
28
-
29
- Args:
30
- param_decls: Option names (e.g., "--name", "-n")
31
- type: Expected type
32
- required: Whether option is required
33
- default: Default value
34
- help: Help text
35
- is_flag: Whether option is a boolean flag
36
- multiple: Whether option can be specified multiple times
37
- count: Whether option counts occurrences
38
- prompt: Whether to prompt for value if not provided
39
- hide_input: Whether to hide input when prompting
40
- confirmation_prompt: Whether to prompt for confirmation
41
- prompt_required: Whether prompt is required
42
- show_default: Whether to show default in help
43
- choices: List of valid choices
44
- case_sensitive: Whether choices are case sensitive
45
- callback: Function to process/validate value
46
- hidden: Whether to hide from help output
47
-
48
- Example:
49
- @command()
50
- @option("--count", "-c", type=int, default=1)
51
- @option("--format", type=str, choices=["json", "yaml"])
52
- @option("--verbose", is_flag=True)
53
- def process(count: int, format: str, verbose: bool):
54
- '''Process data'''
55
- if verbose:
56
- print(f"Processing {count} items as {format}")
57
- """
58
- def decorator(f: Callable) -> Callable:
59
- if not hasattr(f, '_options'):
60
- f._options = []
61
-
62
- f._options.append({
63
- 'param_decls': param_decls,
64
- 'type': type,
65
- 'required': required,
66
- 'default': default,
67
- 'help': help,
68
- 'is_flag': is_flag,
69
- 'multiple': multiple,
70
- 'count': count,
71
- 'prompt': prompt,
72
- 'hide_input': hide_input,
73
- 'confirmation_prompt': confirmation_prompt,
74
- 'prompt_required': prompt_required,
75
- 'show_default': show_default,
76
- 'choices': choices,
77
- 'case_sensitive': case_sensitive,
78
- 'callback': callback,
79
- 'hidden': hidden
80
- })
81
- return f
82
- return decorator
83
-
84
- def envvar(
85
- name: str,
86
- type: Any = str,
87
- required: bool = False,
88
- default: Any = None,
89
- help: str = None
90
- ) -> Callable:
91
- """
92
- Decorator to load option value from environment variable.
93
-
94
- Args:
95
- name: Environment variable name
96
- type: Expected type
97
- required: Whether variable is required
98
- default: Default value if not set
99
- help: Help text
100
-
101
- Example:
102
- @command()
103
- @envvar("API_KEY", required=True)
104
- @envvar("API_URL", default="https://api.example.com")
105
- def api_call(api_key: str, api_url: str):
106
- '''Make API call'''
107
- print(f"Calling {api_url} with key {api_key}")
108
- """
109
- def decorator(f: Callable) -> Callable:
110
- if not hasattr(f, '_envvars'):
111
- f._envvars = []
112
-
113
- f._envvars.append({
114
- 'name': name,
115
- 'type': type,
116
- 'required': required,
117
- 'default': default,
118
- 'help': help
119
- })
120
- return f
121
- return decorator
122
-
123
- def config_file(
124
- path: str = None,
125
- section: str = None,
126
- required: bool = False,
127
- auto_create: bool = True,
128
- format: str = 'json'
129
- ) -> Callable:
130
- """
131
- Decorator to load configuration from file.
132
-
133
- Args:
134
- path: Config file path
135
- section: Config section to load
136
- required: Whether config is required
137
- auto_create: Whether to create file if missing
138
- format: File format (json, yaml, ini)
139
-
140
- Example:
141
- @command()
142
- @config_file("~/.myapp/config.json")
143
- def setup(config: dict):
144
- '''Setup application'''
145
- print(f"Database: {config.get('database')}")
146
-
147
- @command()
148
- @config_file("config.ini", section="api")
149
- def api(config: dict):
150
- '''Make API call'''
151
- print(f"URL: {config.get('url')}")
152
- """
153
- def decorator(f: Callable) -> Callable:
154
- f._config = {
155
- 'path': path,
156
- 'section': section,
157
- 'required': required,
158
- 'auto_create': auto_create,
159
- 'format': format
160
- }
161
- return f
162
- return decorator
163
-
164
- def version_option(
165
- version: str = None,
166
- prog_name: str = None,
167
- message: str = None,
168
- package_name: str = None
169
- ) -> Callable:
170
- """
171
- Decorator to add version option to command.
172
-
173
- Args:
174
- version: Version string
175
- prog_name: Program name
176
- message: Custom version message
177
- package_name: Package name to get version from
178
-
179
- Example:
180
- @command()
181
- @version_option(version="1.0.0")
182
- def main():
183
- '''Main command'''
184
- pass
185
- """
186
- def decorator(f: Callable) -> Callable:
187
- f._version = {
188
- 'version': version,
189
- 'prog_name': prog_name,
190
- 'message': message,
191
- 'package_name': package_name
192
- }
193
- return f
194
- return decorator
195
-
196
- def help_option(
197
- param_decls: List[str] = None,
198
- help: str = None
199
- ) -> Callable:
200
- """
201
- Decorator to customize help option.
202
-
203
- Args:
204
- param_decls: Help option flags
205
- help: Help text
206
-
207
- Example:
208
- @command()
209
- @help_option(["--help", "-h"], "Show this message")
210
- def main():
211
- '''Main command'''
212
- pass
213
- """
214
- def decorator(f: Callable) -> Callable:
215
- f._help_option = {
216
- 'param_decls': param_decls or ['--help', '-h'],
217
- 'help': help or 'Show this message and exit.'
218
- }
219
- return f
220
- return decorator
@@ -1,252 +0,0 @@
1
- """Output formatting decorators for SwiftCLI."""
2
-
3
- from functools import wraps
4
- from typing import Any, Callable, List, Optional, Union
5
-
6
- from rich.console import Console
7
- from rich.table import Table
8
- from rich.progress import (
9
- Progress,
10
- SpinnerColumn,
11
- TextColumn,
12
- BarColumn,
13
- TaskProgressColumn,
14
- TimeRemainingColumn
15
- )
16
- from rich.panel import Panel
17
-
18
- console = Console()
19
-
20
- def table_output(
21
- headers: List[str],
22
- title: Optional[str] = None,
23
- style: str = "default",
24
- show_lines: bool = False,
25
- expand: bool = False
26
- ) -> Callable:
27
- """
28
- Decorator to format command output as a table.
29
-
30
- Args:
31
- headers: Column headers
32
- title: Table title
33
- style: Table style
34
- show_lines: Show row/column lines
35
- expand: Expand table to terminal width
36
-
37
- Example:
38
- @command()
39
- @table_output(["ID", "Name", "Status"])
40
- def list_users():
41
- '''List all users'''
42
- return [
43
- [1, "John", "Active"],
44
- [2, "Jane", "Inactive"]
45
- ]
46
- """
47
- def decorator(f: Callable) -> Callable:
48
- @wraps(f)
49
- def wrapper(*args, **kwargs):
50
- result = f(*args, **kwargs)
51
- if result:
52
- table = Table(
53
- title=title,
54
- show_header=True,
55
- header_style="bold blue",
56
- show_lines=show_lines,
57
- expand=expand
58
- )
59
-
60
- # Add columns
61
- for header in headers:
62
- table.add_column(header)
63
-
64
- # Add rows
65
- for row in result:
66
- table.add_row(*[str(cell) for cell in row])
67
-
68
- console.print(table)
69
- return result
70
- return wrapper
71
- return decorator
72
-
73
- def progress(
74
- description: str = None,
75
- total: Optional[int] = None,
76
- transient: bool = False,
77
- show_bar: bool = True,
78
- show_percentage: bool = True,
79
- show_time: bool = True
80
- ) -> Callable:
81
- """
82
- Decorator to show progress for long-running commands.
83
-
84
- The decorated function should be a generator that yields
85
- progress updates.
86
-
87
- Args:
88
- description: Task description
89
- total: Total number of steps
90
- transient: Remove progress when done
91
- show_bar: Show progress bar
92
- show_percentage: Show percentage complete
93
- show_time: Show time remaining
94
-
95
- Example:
96
- @command()
97
- @progress("Processing files")
98
- def process(files: List[str]):
99
- '''Process multiple files'''
100
- for file in files:
101
- # Process file
102
- yield f"Processing {file}..."
103
- """
104
- def decorator(f: Callable) -> Callable:
105
- @wraps(f)
106
- def wrapper(*args, **kwargs):
107
- columns = []
108
- columns.append(SpinnerColumn())
109
- columns.append(TextColumn("[progress.description]{task.description}"))
110
-
111
- if show_bar:
112
- columns.append(BarColumn())
113
- if show_percentage:
114
- columns.append(TaskProgressColumn())
115
- if show_time:
116
- columns.append(TimeRemainingColumn())
117
-
118
- with Progress(*columns, transient=transient) as progress:
119
- task = progress.add_task(
120
- description or f.__name__,
121
- total=total
122
- )
123
-
124
- try:
125
- for update in f(*args, **kwargs):
126
- if isinstance(update, (int, float)):
127
- # Update progress by number
128
- progress.update(task, advance=update)
129
- elif isinstance(update, str):
130
- # Update description
131
- progress.update(task, description=update)
132
- elif isinstance(update, dict):
133
- # Update multiple attributes
134
- progress.update(task, **update)
135
- else:
136
- # Just advance by 1
137
- progress.update(task, advance=1)
138
- except Exception as e:
139
- progress.update(task, description=f"Error: {str(e)}")
140
- raise
141
- finally:
142
- progress.update(task, completed=total or 100)
143
-
144
- return wrapper
145
- return decorator
146
-
147
- def panel_output(
148
- title: Optional[str] = None,
149
- style: str = "default",
150
- expand: bool = True,
151
- padding: Union[int, tuple] = 1
152
- ) -> Callable:
153
- """
154
- Decorator to display command output in a panel.
155
-
156
- Args:
157
- title: Panel title
158
- style: Panel style
159
- expand: Expand panel to terminal width
160
- padding: Panel padding
161
-
162
- Example:
163
- @command()
164
- @panel_output(title="System Status")
165
- def status():
166
- '''Show system status'''
167
- return "All systems operational"
168
- """
169
- def decorator(f: Callable) -> Callable:
170
- @wraps(f)
171
- def wrapper(*args, **kwargs):
172
- result = f(*args, **kwargs)
173
- if result:
174
- panel = Panel(
175
- str(result),
176
- title=title,
177
- style=style,
178
- expand=expand,
179
- padding=padding
180
- )
181
- console.print(panel)
182
- return result
183
- return wrapper
184
- return decorator
185
-
186
- def format_output(
187
- template: str,
188
- style: Optional[str] = None
189
- ) -> Callable:
190
- """
191
- Decorator to format command output using a template.
192
-
193
- Args:
194
- template: Format string template
195
- style: Rich style string
196
-
197
- Example:
198
- @command()
199
- @format_output("Created user {name} with ID {id}")
200
- def create_user(name: str):
201
- '''Create a new user'''
202
- return {"name": name, "id": 123}
203
- """
204
- def decorator(f: Callable) -> Callable:
205
- @wraps(f)
206
- def wrapper(*args, **kwargs):
207
- result = f(*args, **kwargs)
208
- if result:
209
- if isinstance(result, dict):
210
- output = template.format(**result)
211
- else:
212
- output = template.format(result)
213
-
214
- if style:
215
- console.print(output, style=style)
216
- else:
217
- console.print(output)
218
- return result
219
- return wrapper
220
- return decorator
221
-
222
- def pager_output(
223
- use_pager: bool = True,
224
- style: Optional[str] = None
225
- ) -> Callable:
226
- """
227
- Decorator to display command output in a pager.
228
-
229
- Args:
230
- use_pager: Whether to use pager
231
- style: Rich style string
232
-
233
- Example:
234
- @command()
235
- @pager_output()
236
- def show_logs():
237
- '''Show application logs'''
238
- return "Very long log output..."
239
- """
240
- def decorator(f: Callable) -> Callable:
241
- @wraps(f)
242
- def wrapper(*args, **kwargs):
243
- result = f(*args, **kwargs)
244
- if result:
245
- with console.pager(styles=use_pager):
246
- if style:
247
- console.print(result, style=style)
248
- else:
249
- console.print(result)
250
- return result
251
- return wrapper
252
- return decorator
@@ -1,21 +0,0 @@
1
- """Exception classes for SwiftCLI."""
2
-
3
- class SwiftCLIException(Exception):
4
- """Base exception class for SwiftCLI."""
5
- pass
6
-
7
- class UsageError(SwiftCLIException):
8
- """Raised when CLI is used incorrectly."""
9
- pass
10
-
11
- class BadParameter(UsageError):
12
- """Raised when a parameter is invalid."""
13
- pass
14
-
15
- class ConfigError(SwiftCLIException):
16
- """Raised when there is a configuration error."""
17
- pass
18
-
19
- class PluginError(SwiftCLIException):
20
- """Raised when there is a plugin error."""
21
- pass