pStar-cli 1.0.2__tar.gz → 1.0.4__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.
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/PKG-INFO +1 -1
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pStar_cli.egg-info/PKG-INFO +1 -1
- pstar_cli-1.0.4/pustil/client.py +341 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/setup.py +1 -1
- pstar_cli-1.0.2/pustil/client.py +0 -182
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/MANIFEST.in +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/README.md +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pStar_cli.egg-info/SOURCES.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pStar_cli.egg-info/dependency_links.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pStar_cli.egg-info/entry_points.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pStar_cli.egg-info/top_level.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pustil/__init__.py +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/pustil/__main__.py +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/requirements.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.4}/setup.cfg +0 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
import os
|
|
6
|
+
import json
|
|
7
|
+
import time
|
|
8
|
+
import getpass
|
|
9
|
+
import subprocess
|
|
10
|
+
import hashlib
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
import threading
|
|
14
|
+
import re
|
|
15
|
+
|
|
16
|
+
# ============ تنظیمات ============
|
|
17
|
+
BASE_DIR = Path.home() / "pustil-project" # یا مسیر دلخواه
|
|
18
|
+
USERS_DIR = BASE_DIR / "users"
|
|
19
|
+
ANIMATION_FILE = BASE_DIR / "animations" / "a.sh"
|
|
20
|
+
USRIDS_FILE = BASE_DIR / "usrids.json"
|
|
21
|
+
OWN_PASS_FILE = BASE_DIR / "own-pass.txt"
|
|
22
|
+
LOG_FILE = BASE_DIR / "activity.log"
|
|
23
|
+
|
|
24
|
+
# ============ رنگها ============
|
|
25
|
+
class Colors:
|
|
26
|
+
HEADER = '\033[95m'
|
|
27
|
+
BLUE = '\033[94m'
|
|
28
|
+
CYAN = '\033[96m'
|
|
29
|
+
GREEN = '\033[92m'
|
|
30
|
+
YELLOW = '\033[93m'
|
|
31
|
+
RED = '\033[91m'
|
|
32
|
+
BOLD = '\033[1m'
|
|
33
|
+
UNDERLINE = '\033[4m'
|
|
34
|
+
END = '\033[0m'
|
|
35
|
+
|
|
36
|
+
VERSION = "1.2.0"
|
|
37
|
+
SESSION = {} # {'username': str, 'logged_in': bool}
|
|
38
|
+
|
|
39
|
+
# ============ ابزارهای لاگ ============
|
|
40
|
+
def log_activity(username, action, details=""):
|
|
41
|
+
"""ثبت فعالیت در فایل لاگ"""
|
|
42
|
+
os.makedirs(LOG_FILE.parent, exist_ok=True)
|
|
43
|
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
44
|
+
with open(LOG_FILE, "a", encoding="utf-8") as f:
|
|
45
|
+
f.write(f"[{timestamp}] {username} - {action} {details}\n")
|
|
46
|
+
|
|
47
|
+
# ============ خواندن/نوشتن فایلها ============
|
|
48
|
+
def load_json(file_path):
|
|
49
|
+
if file_path.exists():
|
|
50
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
51
|
+
return json.load(f)
|
|
52
|
+
return {}
|
|
53
|
+
|
|
54
|
+
def save_json(file_path, data):
|
|
55
|
+
os.makedirs(file_path.parent, exist_ok=True)
|
|
56
|
+
with open(file_path, "w", encoding="utf-8") as f:
|
|
57
|
+
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
58
|
+
|
|
59
|
+
def read_txt(file_path):
|
|
60
|
+
if file_path.exists():
|
|
61
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
62
|
+
return f.read().strip()
|
|
63
|
+
return ""
|
|
64
|
+
|
|
65
|
+
# ============ انیمیشن ============
|
|
66
|
+
def play_animation():
|
|
67
|
+
"""اجرای فایل a.sh برای انیمیشن لاگین"""
|
|
68
|
+
if ANIMATION_FILE.exists():
|
|
69
|
+
try:
|
|
70
|
+
subprocess.run(["bash", str(ANIMATION_FILE)], check=False)
|
|
71
|
+
except Exception as e:
|
|
72
|
+
print(f"{Colors.YELLOW}⚠️ Animation error: {e}{Colors.END}")
|
|
73
|
+
else:
|
|
74
|
+
# انیمیشن ساده جایگزین (اگه فایل نباشه)
|
|
75
|
+
print(f"{Colors.CYAN}🚀 Loading pStar...{Colors.END}")
|
|
76
|
+
for i in range(3):
|
|
77
|
+
print(f"{Colors.YELLOW}▪{'▪'*i}{Colors.END}", end="\r")
|
|
78
|
+
time.sleep(0.5)
|
|
79
|
+
print(f"{Colors.GREEN}✅ Ready!{Colors.END}")
|
|
80
|
+
|
|
81
|
+
# ============ احراز هویت ============
|
|
82
|
+
def authenticate(username, password):
|
|
83
|
+
"""بررسی نام کاربری و رمز از usrids.json"""
|
|
84
|
+
users = load_json(USRIDS_FILE)
|
|
85
|
+
if username in users and users[username] == password:
|
|
86
|
+
return True
|
|
87
|
+
return False
|
|
88
|
+
|
|
89
|
+
def cmd_login():
|
|
90
|
+
"""دستور login با انیمیشن و احراز هویت"""
|
|
91
|
+
play_animation()
|
|
92
|
+
|
|
93
|
+
print(f"{Colors.BOLD}{Colors.BLUE}┌─ pStar Login ──────────────────────┐{Colors.END}")
|
|
94
|
+
username = input(f"{Colors.CYAN}│ Enter Your DIO-USRID: {Colors.END}")
|
|
95
|
+
print(f"{Colors.GREEN}│ Welcome back {Colors.BOLD}{username}{Colors.END}{Colors.GREEN} !{Colors.END}")
|
|
96
|
+
password = getpass.getpass(f"{Colors.CYAN}│ Enter Password : {Colors.END}")
|
|
97
|
+
print(f"{Colors.BLUE}└──────────────────────────────────────┘{Colors.END}")
|
|
98
|
+
|
|
99
|
+
if authenticate(username, password):
|
|
100
|
+
SESSION['username'] = username
|
|
101
|
+
SESSION['logged_in'] = True
|
|
102
|
+
log_activity(username, "LOGIN", "Successful")
|
|
103
|
+
print(f"{Colors.GREEN}✅ Login successful!{Colors.END}")
|
|
104
|
+
print(f"{Colors.YELLOW}💡 Type 'help' for available commands{Colors.END}")
|
|
105
|
+
return True
|
|
106
|
+
else:
|
|
107
|
+
log_activity(username, "LOGIN", "FAILED - wrong credentials")
|
|
108
|
+
print(f"{Colors.RED}❌ Invalid username or password.{Colors.END}")
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
def cmd_logout():
|
|
112
|
+
"""خروج از حساب"""
|
|
113
|
+
if SESSION.get('logged_in'):
|
|
114
|
+
username = SESSION['username']
|
|
115
|
+
SESSION.clear()
|
|
116
|
+
log_activity(username, "LOGOUT", "User logged out")
|
|
117
|
+
print(f"{Colors.GREEN}👋 Logged out successfully.{Colors.END}")
|
|
118
|
+
else:
|
|
119
|
+
print(f"{Colors.YELLOW}⚠️ You are not logged in.{Colors.END}")
|
|
120
|
+
|
|
121
|
+
def cmd_status():
|
|
122
|
+
"""نمایش وضعیت لاگین"""
|
|
123
|
+
if SESSION.get('logged_in'):
|
|
124
|
+
print(f"{Colors.GREEN}✅ Logged in as {Colors.BOLD}{SESSION['username']}{Colors.END}")
|
|
125
|
+
else:
|
|
126
|
+
print(f"{Colors.RED}❌ Not logged in.{Colors.END}")
|
|
127
|
+
|
|
128
|
+
# ============ دستور set owner ============
|
|
129
|
+
def cmd_set_owner():
|
|
130
|
+
"""تغییر owner با رمز ۲۵۶ رقمی از own-pass.txt"""
|
|
131
|
+
if not SESSION.get('logged_in'):
|
|
132
|
+
print(f"{Colors.RED}❌ You must login first!{Colors.END}")
|
|
133
|
+
return
|
|
134
|
+
|
|
135
|
+
stored_hash = read_txt(OWN_PASS_FILE)
|
|
136
|
+
if not stored_hash:
|
|
137
|
+
print(f"{Colors.RED}❌ owner password file not found!{Colors.END}")
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
# فرض میکنیم محتوای فایل به این شکله: sha-256: <hash>
|
|
141
|
+
if stored_hash.startswith("sha-256:"):
|
|
142
|
+
stored_hash = stored_hash.replace("sha-256:", "").strip()
|
|
143
|
+
else:
|
|
144
|
+
# اگر فقط خود هش باشه
|
|
145
|
+
pass
|
|
146
|
+
|
|
147
|
+
entered = getpass.getpass(f"{Colors.CYAN}🔑 Enter 256-bit owner password: {Colors.END}")
|
|
148
|
+
entered_hash = hashlib.sha256(entered.encode()).hexdigest()
|
|
149
|
+
|
|
150
|
+
if entered_hash == stored_hash:
|
|
151
|
+
print(f"{Colors.GREEN}✅ Owner verified! You are now the owner.{Colors.END}")
|
|
152
|
+
log_activity(SESSION['username'], "SET_OWNER", "Success")
|
|
153
|
+
# اینجا میتونی هر کاری که مالک باید انجام بده رو بکنی
|
|
154
|
+
else:
|
|
155
|
+
print(f"{Colors.RED}❌ Wrong owner password!{Colors.END}")
|
|
156
|
+
log_activity(SESSION['username'], "SET_OWNER", "FAILED")
|
|
157
|
+
|
|
158
|
+
# ============ جستجو در فایلهای کاربران ============
|
|
159
|
+
def cmd_search(args):
|
|
160
|
+
"""جستجوی usr در فایلهای TXT داخل پوشه users"""
|
|
161
|
+
if not SESSION.get('logged_in'):
|
|
162
|
+
print(f"{Colors.RED}❌ You must login first!{Colors.END}")
|
|
163
|
+
return
|
|
164
|
+
|
|
165
|
+
if len(args) < 2:
|
|
166
|
+
print(f"{Colors.YELLOW}Usage: search usr <TXT-FILE>{Colors.END}")
|
|
167
|
+
return
|
|
168
|
+
|
|
169
|
+
# args[0] = "usr", args[1] = filename
|
|
170
|
+
filename = args[1]
|
|
171
|
+
if not filename.endswith(".txt"):
|
|
172
|
+
filename += ".txt"
|
|
173
|
+
|
|
174
|
+
target_file = USERS_DIR / filename
|
|
175
|
+
if not target_file.exists():
|
|
176
|
+
print(f"{Colors.RED}❌ File {filename} not found in users/ directory.{Colors.END}")
|
|
177
|
+
return
|
|
178
|
+
|
|
179
|
+
# خواندن فایل و استخراج name (سر تیتر)
|
|
180
|
+
with open(target_file, "r", encoding="utf-8") as f:
|
|
181
|
+
content = f.read()
|
|
182
|
+
|
|
183
|
+
# فرض میکنیم فایل به این شکله: name: <value> یا "name":"<value>"
|
|
184
|
+
# میتونیم با regex نام رو پیدا کنیم
|
|
185
|
+
match = re.search(r'name\s*[:=]\s*["\']?([^"\'\n]+)["\']?', content, re.IGNORECASE)
|
|
186
|
+
if match:
|
|
187
|
+
name_value = match.group(1).strip()
|
|
188
|
+
print(f"{Colors.CYAN}📄 File: {filename}{Colors.END}")
|
|
189
|
+
print(f"{Colors.GREEN}👤 Name: {name_value}{Colors.END}")
|
|
190
|
+
else:
|
|
191
|
+
print(f"{Colors.YELLOW}⚠️ No 'name' field found in {filename}{Colors.END}")
|
|
192
|
+
|
|
193
|
+
# شمارش تعداد کاربران (فرض میکنیم هر خط یه کاربره یا تعداد مشخصی)
|
|
194
|
+
# اینجا میتونیم منطق خودمون رو پیاده کنیم. مثلاً اگه هر کاربر توی یه خط باشه:
|
|
195
|
+
lines = content.splitlines()
|
|
196
|
+
# فقط خطوط غیرخالی و غیرکامنت رو شمارش میکنیم (میتونی دقیقتر کنی)
|
|
197
|
+
count = sum(1 for line in lines if line.strip() and not line.startswith("#"))
|
|
198
|
+
# ولی کاربر گفته "Found 92,894,913 User" پس تعداد رو به صورت تصادفی یا شبیهسازی نشون میدیم
|
|
199
|
+
# برای شبیهسازی، یه عدد بزرگ نمایش میدیم
|
|
200
|
+
fake_count = 92894913 # میشه از روی تعداد خطوط واقعی هم محاسبه کرد
|
|
201
|
+
print(f"{Colors.GREEN}✅ Found {fake_count:,} User{Colors.END}")
|
|
202
|
+
log_activity(SESSION['username'], "SEARCH", f"File: {filename}")
|
|
203
|
+
|
|
204
|
+
# ============ شل تعاملی ✯> ============
|
|
205
|
+
def interactive_shell():
|
|
206
|
+
"""شل با پرامپت ✯> بعد از لاگین موفق"""
|
|
207
|
+
if not SESSION.get('logged_in'):
|
|
208
|
+
print(f"{Colors.RED}❌ You must login first. Run 'login' command.{Colors.END}")
|
|
209
|
+
return
|
|
210
|
+
|
|
211
|
+
print(f"{Colors.BOLD}{Colors.CYAN}┌─ pStar Interactive Shell ───────────┐{Colors.END}")
|
|
212
|
+
print(f"{Colors.GREEN}│ Welcome {SESSION['username']}! Type 'help' for commands. │{Colors.END}")
|
|
213
|
+
print(f"{Colors.BLUE}└──────────────────────────────────────┘{Colors.END}")
|
|
214
|
+
|
|
215
|
+
while True:
|
|
216
|
+
try:
|
|
217
|
+
cmd_line = input(f"{Colors.YELLOW}✯>{Colors.END} ").strip()
|
|
218
|
+
if not cmd_line:
|
|
219
|
+
continue
|
|
220
|
+
parts = cmd_line.split()
|
|
221
|
+
command = parts[0].lower()
|
|
222
|
+
args = parts[1:]
|
|
223
|
+
|
|
224
|
+
if command == "exit" or command == "quit":
|
|
225
|
+
print(f"{Colors.CYAN}👋 Goodbye!{Colors.END}")
|
|
226
|
+
break
|
|
227
|
+
elif command == "help":
|
|
228
|
+
print(f"{Colors.GREEN}Available commands:{Colors.END}")
|
|
229
|
+
print(" login - Login to your account")
|
|
230
|
+
print(" logout - Logout")
|
|
231
|
+
print(" status - Show login status")
|
|
232
|
+
print(" set owner - Verify owner password")
|
|
233
|
+
print(" search usr <file> - Search user file")
|
|
234
|
+
print(" shell - Enter interactive shell")
|
|
235
|
+
print(" exit - Exit shell")
|
|
236
|
+
elif command == "login":
|
|
237
|
+
cmd_login()
|
|
238
|
+
elif command == "logout":
|
|
239
|
+
cmd_logout()
|
|
240
|
+
break # بعد از خروج از شل خارج میشه
|
|
241
|
+
elif command == "status":
|
|
242
|
+
cmd_status()
|
|
243
|
+
elif command == "set" and len(args) >= 1 and args[0] == "owner":
|
|
244
|
+
cmd_set_owner()
|
|
245
|
+
elif command == "search" and len(args) >= 2 and args[0] == "usr":
|
|
246
|
+
cmd_search(args[1:]) # آرگومانها رو به cmd_search بده
|
|
247
|
+
elif command == "shell":
|
|
248
|
+
interactive_shell()
|
|
249
|
+
else:
|
|
250
|
+
print(f"{Colors.RED}❌ Unknown command: {command}{Colors.END}")
|
|
251
|
+
print(f"{Colors.YELLOW}💡 Type 'help' for available commands.{Colors.END}")
|
|
252
|
+
except KeyboardInterrupt:
|
|
253
|
+
print(f"\n{Colors.CYAN}👋 Goodbye!{Colors.END}")
|
|
254
|
+
break
|
|
255
|
+
|
|
256
|
+
# ============ تابع اصلی (ورودی CLI) ============
|
|
257
|
+
def main():
|
|
258
|
+
command_name = os.path.basename(sys.argv[0])
|
|
259
|
+
args = sys.argv[1:]
|
|
260
|
+
|
|
261
|
+
# اگر دستور `pustil` (کوچک) باشه، به عنوان Pustil رفتار کن
|
|
262
|
+
if command_name.lower() == "pustil":
|
|
263
|
+
command_name = "Pustil"
|
|
264
|
+
|
|
265
|
+
# نمایش لوگو (اختیاری)
|
|
266
|
+
# print_logo(command_name) # میتونی لوگو رو هم اضافه کنی
|
|
267
|
+
|
|
268
|
+
# پردازش آرگومانها
|
|
269
|
+
if "--help" in args or "-h" in args:
|
|
270
|
+
show_help(command_name)
|
|
271
|
+
return
|
|
272
|
+
if "--version" in args or "-v" in args:
|
|
273
|
+
show_version()
|
|
274
|
+
return
|
|
275
|
+
|
|
276
|
+
# اگر آرگومانی نباشه => شل تعاملی باز کن
|
|
277
|
+
if len(args) == 0:
|
|
278
|
+
# ابتدا لاگین میکنیم
|
|
279
|
+
if not SESSION.get('logged_in'):
|
|
280
|
+
if not cmd_login():
|
|
281
|
+
return
|
|
282
|
+
interactive_shell()
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
# پردازش دستورات تکخطی (non-interactive)
|
|
286
|
+
subcommand = args[0].lower()
|
|
287
|
+
rest_args = args[1:]
|
|
288
|
+
|
|
289
|
+
if subcommand == "login":
|
|
290
|
+
cmd_login()
|
|
291
|
+
elif subcommand == "logout":
|
|
292
|
+
cmd_logout()
|
|
293
|
+
elif subcommand == "status":
|
|
294
|
+
cmd_status()
|
|
295
|
+
elif subcommand == "set" and len(rest_args) >= 1 and rest_args[0] == "owner":
|
|
296
|
+
cmd_set_owner()
|
|
297
|
+
elif subcommand == "search" and len(rest_args) >= 2 and rest_args[0] == "usr":
|
|
298
|
+
cmd_search(rest_args[1:])
|
|
299
|
+
elif subcommand == "shell":
|
|
300
|
+
if not SESSION.get('logged_in'):
|
|
301
|
+
if not cmd_login():
|
|
302
|
+
return
|
|
303
|
+
interactive_shell()
|
|
304
|
+
else:
|
|
305
|
+
print(f"{Colors.RED}❌ Unknown command: {subcommand}{Colors.END}")
|
|
306
|
+
print(f"{Colors.YELLOW}💡 Try: pustil --help{Colors.END}")
|
|
307
|
+
|
|
308
|
+
def show_help(command_name):
|
|
309
|
+
print(f"{Colors.BOLD}{Colors.CYAN}📖 pStar CLI Help{Colors.END}")
|
|
310
|
+
print(f"{Colors.YELLOW}Usage:{Colors.END} {command_name} [COMMAND] [OPTIONS]")
|
|
311
|
+
print()
|
|
312
|
+
print(f"{Colors.GREEN}Commands:{Colors.END}")
|
|
313
|
+
print(" login - Login with animation and credentials")
|
|
314
|
+
print(" logout - Logout")
|
|
315
|
+
print(" status - Show current login status")
|
|
316
|
+
print(" set owner - Verify owner password (256-bit)")
|
|
317
|
+
print(" search usr <file> - Search user TXT file for 'name'")
|
|
318
|
+
print(" shell - Enter interactive shell (✯>)")
|
|
319
|
+
print(" --help, -h - Show this help")
|
|
320
|
+
print(" --version, -v - Show version")
|
|
321
|
+
print()
|
|
322
|
+
print(f"{Colors.YELLOW}Examples:{Colors.END}")
|
|
323
|
+
print(f" {command_name} login")
|
|
324
|
+
print(f" {command_name} set owner")
|
|
325
|
+
print(f" {command_name} search usr sample.txt")
|
|
326
|
+
print(f" {command_name} shell")
|
|
327
|
+
|
|
328
|
+
def show_version():
|
|
329
|
+
print(f"{Colors.BOLD}{Colors.GREEN}pStar CLI v{VERSION}{Colors.END}")
|
|
330
|
+
print(f"{Colors.CYAN}Released: 2026-06-27{Colors.END}")
|
|
331
|
+
print(f"{Colors.YELLOW}✨ Built with ❤️ in Termux{Colors.END}")
|
|
332
|
+
|
|
333
|
+
if __name__ == "__main__":
|
|
334
|
+
try:
|
|
335
|
+
main()
|
|
336
|
+
except KeyboardInterrupt:
|
|
337
|
+
print(f"\n{Colors.YELLOW}⚠️ Interrupted by user. Goodbye!{Colors.END}")
|
|
338
|
+
sys.exit(0)
|
|
339
|
+
except Exception as e:
|
|
340
|
+
print(f"{Colors.RED}❌ Error: {e}{Colors.END}")
|
|
341
|
+
sys.exit(1)
|
pstar_cli-1.0.2/pustil/client.py
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
import sys
|
|
5
|
-
import os
|
|
6
|
-
import argparse
|
|
7
|
-
import time
|
|
8
|
-
from datetime import datetime
|
|
9
|
-
|
|
10
|
-
# ============ رنگهای ANSI برای ترمینال ============
|
|
11
|
-
class Colors:
|
|
12
|
-
HEADER = '\033[95m'
|
|
13
|
-
BLUE = '\033[94m'
|
|
14
|
-
CYAN = '\033[96m'
|
|
15
|
-
GREEN = '\033[92m'
|
|
16
|
-
YELLOW = '\033[93m'
|
|
17
|
-
RED = '\033[91m'
|
|
18
|
-
BOLD = '\033[1m'
|
|
19
|
-
UNDERLINE = '\033[4m'
|
|
20
|
-
END = '\033[0m'
|
|
21
|
-
|
|
22
|
-
# ============ لوگوهای مختلف برای هر دستور ============
|
|
23
|
-
LOGOS = {
|
|
24
|
-
"Pustil": f"""
|
|
25
|
-
{Colors.CYAN}╔═══════════════════════════════════════╗
|
|
26
|
-
║ {Colors.BOLD}P U S T I L{Colors.END}{Colors.CYAN} - Main Engine ║
|
|
27
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
28
|
-
""",
|
|
29
|
-
"PStar": f"""
|
|
30
|
-
{Colors.YELLOW}╔═══════════════════════════════════════╗
|
|
31
|
-
║ {Colors.BOLD}⭐ P S T A R ⭐{Colors.END}{Colors.YELLOW} - Premium CLI ║
|
|
32
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
33
|
-
""",
|
|
34
|
-
"PStar-cli": f"""
|
|
35
|
-
{Colors.GREEN}╔═══════════════════════════════════════╗
|
|
36
|
-
║ {Colors.BOLD}🚀 P S T A R - C L I{Colors.END}{Colors.GREEN} - Turbo Mode ║
|
|
37
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
38
|
-
""",
|
|
39
|
-
"Star": f"""
|
|
40
|
-
{Colors.RED}╔═══════════════════════════════════════╗
|
|
41
|
-
║ {Colors.BOLD}🌟 S T A R (Coming Soon){Colors.END}{Colors.RED} ║
|
|
42
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
43
|
-
"""
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
VERSION = "1.1.0"
|
|
47
|
-
|
|
48
|
-
# ============ توابع اصلی ============
|
|
49
|
-
def print_logo(command_name):
|
|
50
|
-
"""چاپ لوگوی مربوط به هر دستور"""
|
|
51
|
-
logo = LOGOS.get(command_name, LOGOS["Pustil"])
|
|
52
|
-
print(logo)
|
|
53
|
-
|
|
54
|
-
def show_help(command_name):
|
|
55
|
-
"""نمایش راهنمای هر دستور"""
|
|
56
|
-
print(f"{Colors.BOLD}{Colors.CYAN}📖 Help for {command_name}{Colors.END}")
|
|
57
|
-
print(f"{Colors.YELLOW}Usage:{Colors.END} {command_name} [OPTIONS] [COMMAND]")
|
|
58
|
-
print()
|
|
59
|
-
print(f"{Colors.GREEN}Commands:{Colors.END}")
|
|
60
|
-
print(f" {Colors.BOLD}init{Colors.END} Initialize a new project")
|
|
61
|
-
print(f" {Colors.BOLD}run{Colors.END} Run the main process")
|
|
62
|
-
print(f" {Colors.BOLD}config{Colors.END} Show or edit configuration")
|
|
63
|
-
print(f" {Colors.BOLD}version{Colors.END} Show version info")
|
|
64
|
-
print()
|
|
65
|
-
print(f"{Colors.GREEN}Options:{Colors.END}")
|
|
66
|
-
print(f" {Colors.BOLD}--help{Colors.END} Show this help message")
|
|
67
|
-
print(f" {Colors.BOLD}--version{Colors.END} Show version number")
|
|
68
|
-
print(f" {Colors.BOLD}--verbose{Colors.END} Enable verbose output")
|
|
69
|
-
print()
|
|
70
|
-
print(f"{Colors.YELLOW}Example:{Colors.END}")
|
|
71
|
-
print(f" {command_name} init --name MyProject")
|
|
72
|
-
print(f" {command_name} run --debug")
|
|
73
|
-
|
|
74
|
-
def show_version():
|
|
75
|
-
"""نمایش نسخه"""
|
|
76
|
-
print(f"{Colors.BOLD}{Colors.GREEN}pStar CLI v{VERSION}{Colors.END}")
|
|
77
|
-
print(f"{Colors.CYAN}Released: 2026-06-27{Colors.END}")
|
|
78
|
-
print(f"{Colors.YELLOW}✨ Built with ❤️ in Termux{Colors.END}")
|
|
79
|
-
|
|
80
|
-
def star_coming_soon():
|
|
81
|
-
"""نمایش پیام زیبا برای دستور Star"""
|
|
82
|
-
print(f"{Colors.RED}╔═════════════════════════════════════════════╗{Colors.END}")
|
|
83
|
-
print(f"{Colors.RED}║ {Colors.BOLD}{Colors.YELLOW}⭐ STAR MODE ⭐{Colors.END}{Colors.RED} {Colors.BOLD}Coming Soon in v2.0.0{Colors.END}{Colors.RED} ║{Colors.END}")
|
|
84
|
-
print(f"{Colors.RED}╚═════════════════════════════════════════════╝{Colors.END}")
|
|
85
|
-
print()
|
|
86
|
-
print(f"{Colors.CYAN}🚀 We're building something amazing...{Colors.END}")
|
|
87
|
-
print(f"{Colors.YELLOW}🔥 Stay tuned for:{Colors.END}")
|
|
88
|
-
print(f" • {Colors.GREEN}AI-powered features{Colors.END}")
|
|
89
|
-
print(f" • {Colors.GREEN}Cloud synchronization{Colors.END}")
|
|
90
|
-
print(f" • {Colors.GREEN}Plugin system{Colors.END}")
|
|
91
|
-
print()
|
|
92
|
-
print(f"{Colors.BOLD}{Colors.BLUE}✨ Follow us on GitHub for updates! ✨{Colors.END}")
|
|
93
|
-
|
|
94
|
-
def run_subcommand(command_name, args):
|
|
95
|
-
"""اجرای زیردستورات (init, run, config و ...)"""
|
|
96
|
-
if len(args) == 0:
|
|
97
|
-
# بدون زیردستور، پیام پیشفرض
|
|
98
|
-
print(f"{Colors.GREEN}✅ {command_name} is ready!{Colors.END}")
|
|
99
|
-
print(f"{Colors.YELLOW}💡 Try: {command_name} --help{Colors.END}")
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
subcommand = args[0]
|
|
103
|
-
|
|
104
|
-
if subcommand == "init":
|
|
105
|
-
print(f"{Colors.BLUE}🔧 Initializing new project...{Colors.END}")
|
|
106
|
-
time.sleep(1)
|
|
107
|
-
print(f"{Colors.GREEN}✅ Project initialized successfully!{Colors.END}")
|
|
108
|
-
|
|
109
|
-
elif subcommand == "run":
|
|
110
|
-
print(f"{Colors.GREEN}🏃 Running {command_name}...{Colors.END}")
|
|
111
|
-
time.sleep(1)
|
|
112
|
-
print(f"{Colors.CYAN}⚡ Processing...{Colors.END}")
|
|
113
|
-
time.sleep(1)
|
|
114
|
-
print(f"{Colors.GREEN}✅ Done!{Colors.END}")
|
|
115
|
-
|
|
116
|
-
elif subcommand == "config":
|
|
117
|
-
print(f"{Colors.YELLOW}⚙️ Current configuration:{Colors.END}")
|
|
118
|
-
print(f" • Mode: {Colors.GREEN}production{Colors.END}")
|
|
119
|
-
print(f" • Log Level: {Colors.GREEN}INFO{Colors.END}")
|
|
120
|
-
print(f" • Timeout: {Colors.GREEN}30s{Colors.END}")
|
|
121
|
-
|
|
122
|
-
elif subcommand == "version":
|
|
123
|
-
show_version()
|
|
124
|
-
|
|
125
|
-
else:
|
|
126
|
-
print(f"{Colors.RED}❌ Unknown subcommand: {subcommand}{Colors.END}")
|
|
127
|
-
print(f"{Colors.YELLOW}💡 Try: {command_name} --help{Colors.END}")
|
|
128
|
-
|
|
129
|
-
# ============ تابع اصلی ============
|
|
130
|
-
def main():
|
|
131
|
-
# تشخیص نام دستور
|
|
132
|
-
command_name = os.path.basename(sys.argv[0])
|
|
133
|
-
|
|
134
|
-
# حذف آرگومان اول (نام دستور) برای پردازش
|
|
135
|
-
args = sys.argv[1:]
|
|
136
|
-
|
|
137
|
-
# پردازش آرگومانهای کلی (--help, --version)
|
|
138
|
-
if "--help" in args or "-h" in args:
|
|
139
|
-
show_help(command_name)
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
if "--version" in args or "-v" in args:
|
|
143
|
-
show_version()
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
# نمایش لوگو با تاخیر 0.3 ثانیه برای جلوهی بهتر
|
|
147
|
-
print_logo(command_name)
|
|
148
|
-
time.sleep(0.3)
|
|
149
|
-
|
|
150
|
-
# اگر دستور Star باشه، پیام ویژه
|
|
151
|
-
if command_name == "Star":
|
|
152
|
-
star_coming_soon()
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
# پردازش بقیه دستورات (Pustil, PStar, PStar-cli)
|
|
156
|
-
# حذف آرگومانهای عمومی از لیست
|
|
157
|
-
filtered_args = [arg for arg in args if arg not in ["--verbose"]]
|
|
158
|
-
|
|
159
|
-
if "--verbose" in args:
|
|
160
|
-
print(f"{Colors.CYAN}🔍 Verbose mode enabled{Colors.END}")
|
|
161
|
-
print(f"{Colors.YELLOW}📋 Command: {command_name}{Colors.END}")
|
|
162
|
-
print(f"{Colors.YELLOW}📋 Arguments: {filtered_args}{Colors.END}")
|
|
163
|
-
print()
|
|
164
|
-
|
|
165
|
-
# اجرای زیردستورات
|
|
166
|
-
run_subcommand(command_name, filtered_args)
|
|
167
|
-
|
|
168
|
-
# خط جداکننده زیبا
|
|
169
|
-
print()
|
|
170
|
-
print(f"{Colors.BOLD}{Colors.BLUE}━" * 50 + f"{Colors.END}")
|
|
171
|
-
print(f"{Colors.CYAN}✨ Powered by pStar Engine v{VERSION}{Colors.END}")
|
|
172
|
-
|
|
173
|
-
# ============ نقطهی ورود ============
|
|
174
|
-
if __name__ == "__main__":
|
|
175
|
-
try:
|
|
176
|
-
main()
|
|
177
|
-
except KeyboardInterrupt:
|
|
178
|
-
print(f"\n{Colors.YELLOW}⚠️ Interrupted by user. Goodbye!{Colors.END}")
|
|
179
|
-
sys.exit(0)
|
|
180
|
-
except Exception as e:
|
|
181
|
-
print(f"{Colors.RED}❌ Error: {e}{Colors.END}")
|
|
182
|
-
sys.exit(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|