pStar-cli 1.0.3__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.3 → pstar_cli-1.0.4}/PKG-INFO +1 -1
- {pstar_cli-1.0.3 → 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.3 → pstar_cli-1.0.4}/setup.py +1 -1
- pstar_cli-1.0.3/pustil/client.py +0 -279
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/MANIFEST.in +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/README.md +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/pStar_cli.egg-info/SOURCES.txt +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/pStar_cli.egg-info/dependency_links.txt +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/pStar_cli.egg-info/entry_points.txt +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/pStar_cli.egg-info/top_level.txt +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/pustil/__init__.py +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/pustil/__main__.py +0 -0
- {pstar_cli-1.0.3 → pstar_cli-1.0.4}/requirements.txt +0 -0
- {pstar_cli-1.0.3 → 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.3/pustil/client.py
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
import sys
|
|
5
|
-
import os
|
|
6
|
-
import time
|
|
7
|
-
import getpass
|
|
8
|
-
import json
|
|
9
|
-
from datetime import datetime
|
|
10
|
-
from pathlib import Path
|
|
11
|
-
|
|
12
|
-
# ============ رنگهای ANSI ============
|
|
13
|
-
class Colors:
|
|
14
|
-
HEADER = '\033[95m'
|
|
15
|
-
BLUE = '\033[94m'
|
|
16
|
-
CYAN = '\033[96m'
|
|
17
|
-
GREEN = '\033[92m'
|
|
18
|
-
YELLOW = '\033[93m'
|
|
19
|
-
RED = '\033[91m'
|
|
20
|
-
BOLD = '\033[1m'
|
|
21
|
-
UNDERLINE = '\033[4m'
|
|
22
|
-
END = '\033[0m'
|
|
23
|
-
|
|
24
|
-
# ============ لوگوها ============
|
|
25
|
-
LOGOS = {
|
|
26
|
-
"Pustil": f"""
|
|
27
|
-
{Colors.CYAN}╔═══════════════════════════════════════╗
|
|
28
|
-
║ {Colors.BOLD}P U S T I L{Colors.END}{Colors.CYAN} - Main Engine ║
|
|
29
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
30
|
-
""",
|
|
31
|
-
"PStar": f"""
|
|
32
|
-
{Colors.YELLOW}╔═══════════════════════════════════════╗
|
|
33
|
-
║ {Colors.BOLD}⭐ P S T A R ⭐{Colors.END}{Colors.YELLOW} - Premium CLI ║
|
|
34
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
35
|
-
""",
|
|
36
|
-
"PStar-cli": f"""
|
|
37
|
-
{Colors.GREEN}╔═══════════════════════════════════════╗
|
|
38
|
-
║ {Colors.BOLD}🚀 P S T A R - C L I{Colors.END}{Colors.GREEN} - Turbo Mode ║
|
|
39
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
40
|
-
""",
|
|
41
|
-
"Star": f"""
|
|
42
|
-
{Colors.RED}╔═══════════════════════════════════════╗
|
|
43
|
-
║ {Colors.BOLD}🌟 S T A R (Coming Soon){Colors.END}{Colors.RED} ║
|
|
44
|
-
╚═══════════════════════════════════════╝{Colors.END}
|
|
45
|
-
"""
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
VERSION = "1.2.0"
|
|
49
|
-
TOKEN_FILE = Path.home() / ".pustil_token"
|
|
50
|
-
|
|
51
|
-
# ============ مدیریت توکن ============
|
|
52
|
-
def save_token(username, token):
|
|
53
|
-
"""ذخیرهی توکن در فایل"""
|
|
54
|
-
data = {"username": username, "token": token, "timestamp": datetime.now().isoformat()}
|
|
55
|
-
with open(TOKEN_FILE, "w") as f:
|
|
56
|
-
json.dump(data, f)
|
|
57
|
-
os.chmod(TOKEN_FILE, 0o600) # فقط خود کاربر بخونه
|
|
58
|
-
|
|
59
|
-
def load_token():
|
|
60
|
-
"""بارگذاری توکن از فایل"""
|
|
61
|
-
if TOKEN_FILE.exists():
|
|
62
|
-
with open(TOKEN_FILE, "r") as f:
|
|
63
|
-
return json.load(f)
|
|
64
|
-
return None
|
|
65
|
-
|
|
66
|
-
def clear_token():
|
|
67
|
-
"""پاک کردن توکن (logout)"""
|
|
68
|
-
if TOKEN_FILE.exists():
|
|
69
|
-
TOKEN_FILE.unlink()
|
|
70
|
-
|
|
71
|
-
# ============ توابع اصلی ============
|
|
72
|
-
def print_logo(command_name):
|
|
73
|
-
logo = LOGOS.get(command_name, LOGOS["Pustil"])
|
|
74
|
-
print(logo)
|
|
75
|
-
|
|
76
|
-
def show_help(command_name):
|
|
77
|
-
print(f"{Colors.BOLD}{Colors.CYAN}📖 Help for {command_name}{Colors.END}")
|
|
78
|
-
print(f"{Colors.YELLOW}Usage:{Colors.END} {command_name} [OPTIONS] [COMMAND]")
|
|
79
|
-
print()
|
|
80
|
-
print(f"{Colors.GREEN}Commands:{Colors.END}")
|
|
81
|
-
print(f" {Colors.BOLD}init{Colors.END} Initialize a new project")
|
|
82
|
-
print(f" {Colors.BOLD}run{Colors.END} Run the main process")
|
|
83
|
-
print(f" {Colors.BOLD}config{Colors.END} Show or edit configuration")
|
|
84
|
-
print(f" {Colors.BOLD}login{Colors.END} Login to your account")
|
|
85
|
-
print(f" {Colors.BOLD}logout{Colors.END} Logout from your account")
|
|
86
|
-
print(f" {Colors.BOLD}status{Colors.END} Show login status")
|
|
87
|
-
print(f" {Colors.BOLD}shell{Colors.END} Enter interactive shell")
|
|
88
|
-
print(f" {Colors.BOLD}version{Colors.END} Show version info")
|
|
89
|
-
print()
|
|
90
|
-
print(f"{Colors.GREEN}Options:{Colors.END}")
|
|
91
|
-
print(f" {Colors.BOLD}--help{Colors.END} Show this help message")
|
|
92
|
-
print(f" {Colors.BOLD}--version{Colors.END} Show version number")
|
|
93
|
-
print(f" {Colors.BOLD}--verbose{Colors.END} Enable verbose output")
|
|
94
|
-
print()
|
|
95
|
-
print(f"{Colors.YELLOW}Example:{Colors.END}")
|
|
96
|
-
print(f" {command_name} login")
|
|
97
|
-
print(f" {command_name} init --name MyProject")
|
|
98
|
-
|
|
99
|
-
def show_version():
|
|
100
|
-
print(f"{Colors.BOLD}{Colors.GREEN}pStar CLI v{VERSION}{Colors.END}")
|
|
101
|
-
print(f"{Colors.CYAN}Released: 2026-06-27{Colors.END}")
|
|
102
|
-
print(f"{Colors.YELLOW}✨ Built with ❤️ in Termux{Colors.END}")
|
|
103
|
-
|
|
104
|
-
def star_coming_soon():
|
|
105
|
-
print(f"{Colors.RED}╔═════════════════════════════════════════════╗{Colors.END}")
|
|
106
|
-
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}")
|
|
107
|
-
print(f"{Colors.RED}╚═════════════════════════════════════════════╝{Colors.END}")
|
|
108
|
-
print()
|
|
109
|
-
print(f"{Colors.CYAN}🚀 We're building something amazing...{Colors.END}")
|
|
110
|
-
print(f"{Colors.YELLOW}🔥 Stay tuned for:{Colors.END}")
|
|
111
|
-
print(f" • {Colors.GREEN}AI-powered features{Colors.END}")
|
|
112
|
-
print(f" • {Colors.GREEN}Cloud synchronization{Colors.END}")
|
|
113
|
-
print(f" • {Colors.GREEN}Plugin system{Colors.END}")
|
|
114
|
-
print()
|
|
115
|
-
print(f"{Colors.BOLD}{Colors.BLUE}✨ Follow us on GitHub for updates! ✨{Colors.END}")
|
|
116
|
-
|
|
117
|
-
def cmd_login():
|
|
118
|
-
"""زیردستور login - ورود به حساب"""
|
|
119
|
-
print(f"{Colors.BLUE}🔐 Login to pStar{Colors.END}")
|
|
120
|
-
username = input(f"{Colors.CYAN}👤 Username: {Colors.END}")
|
|
121
|
-
password = getpass.getpass(f"{Colors.CYAN}🔑 Password: {Colors.END}")
|
|
122
|
-
|
|
123
|
-
# شبیهسازی احراز هویت (اینجا میتونی API واقعی وصل کنی)
|
|
124
|
-
if username and password:
|
|
125
|
-
# توکن ساختگی (در عمل از سرور دریافت میشه)
|
|
126
|
-
fake_token = f"pstar_{username}_{int(time.time())}"
|
|
127
|
-
save_token(username, fake_token)
|
|
128
|
-
print(f"{Colors.GREEN}✅ Login successful! Welcome back, {Colors.BOLD}{username}{Colors.END}{Colors.GREEN}! 🎉{Colors.END}")
|
|
129
|
-
print(f"{Colors.YELLOW}💡 Your session token: {fake_token[:20]}...{Colors.END}")
|
|
130
|
-
else:
|
|
131
|
-
print(f"{Colors.RED}❌ Username and password cannot be empty!{Colors.END}")
|
|
132
|
-
|
|
133
|
-
def cmd_logout():
|
|
134
|
-
"""زیردستور logout - خروج از حساب"""
|
|
135
|
-
token_data = load_token()
|
|
136
|
-
if token_data:
|
|
137
|
-
clear_token()
|
|
138
|
-
print(f"{Colors.GREEN}👋 Logged out successfully. Goodbye, {Colors.BOLD}{token_data.get('username', 'User')}{Colors.END}{Colors.GREEN}!{Colors.END}")
|
|
139
|
-
else:
|
|
140
|
-
print(f"{Colors.YELLOW}⚠️ You are not logged in.{Colors.END}")
|
|
141
|
-
|
|
142
|
-
def cmd_status():
|
|
143
|
-
"""زیردستور status - نمایش وضعیت"""
|
|
144
|
-
token_data = load_token()
|
|
145
|
-
if token_data:
|
|
146
|
-
print(f"{Colors.GREEN}✅ You are logged in as {Colors.BOLD}{token_data['username']}{Colors.END}")
|
|
147
|
-
print(f"{Colors.CYAN}📅 Session started: {token_data.get('timestamp', 'Unknown')}{Colors.END}")
|
|
148
|
-
print(f"{Colors.YELLOW}🔑 Token: {token_data['token'][:20]}...{Colors.END}")
|
|
149
|
-
else:
|
|
150
|
-
print(f"{Colors.RED}❌ You are not logged in. Please run: {Colors.BOLD}Pustil login{Colors.END}")
|
|
151
|
-
|
|
152
|
-
def interactive_shell():
|
|
153
|
-
"""حالت تعاملی (shell)"""
|
|
154
|
-
print(f"{Colors.BOLD}{Colors.CYAN}🚀 pStar Interactive Shell (type 'exit' to quit){Colors.END}")
|
|
155
|
-
print(f"{Colors.YELLOW}💡 Available commands: login, logout, status, help, exit{Colors.END}")
|
|
156
|
-
|
|
157
|
-
while True:
|
|
158
|
-
try:
|
|
159
|
-
cmd = input(f"{Colors.GREEN}pstar> {Colors.END}").strip()
|
|
160
|
-
if not cmd:
|
|
161
|
-
continue
|
|
162
|
-
if cmd.lower() in ["exit", "quit", "q"]:
|
|
163
|
-
print(f"{Colors.CYAN}👋 Goodbye!{Colors.END}")
|
|
164
|
-
break
|
|
165
|
-
elif cmd == "login":
|
|
166
|
-
cmd_login()
|
|
167
|
-
elif cmd == "logout":
|
|
168
|
-
cmd_logout()
|
|
169
|
-
elif cmd == "status":
|
|
170
|
-
cmd_status()
|
|
171
|
-
elif cmd == "help":
|
|
172
|
-
print(f"{Colors.YELLOW}Commands: login, logout, status, help, exit{Colors.END}")
|
|
173
|
-
else:
|
|
174
|
-
print(f"{Colors.RED}❌ Unknown command: {cmd}{Colors.END}")
|
|
175
|
-
except KeyboardInterrupt:
|
|
176
|
-
print(f"\n{Colors.CYAN}👋 Goodbye!{Colors.END}")
|
|
177
|
-
break
|
|
178
|
-
|
|
179
|
-
def run_subcommand(command_name, args):
|
|
180
|
-
"""اجرای زیردستورات"""
|
|
181
|
-
if len(args) == 0:
|
|
182
|
-
# بدون زیردستور => پیشنهاد ورود یا shell
|
|
183
|
-
token_data = load_token()
|
|
184
|
-
if token_data:
|
|
185
|
-
print(f"{Colors.GREEN}✅ Welcome back, {Colors.BOLD}{token_data['username']}{Colors.END}{Colors.GREEN}!{Colors.END}")
|
|
186
|
-
print(f"{Colors.YELLOW}💡 Type '{command_name} shell' for interactive mode{Colors.END}")
|
|
187
|
-
else:
|
|
188
|
-
print(f"{Colors.GREEN}✅ {command_name} is ready!{Colors.END}")
|
|
189
|
-
print(f"{Colors.YELLOW}💡 Try: {command_name} login or {command_name} --help{Colors.END}")
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
subcommand = args[0]
|
|
193
|
-
|
|
194
|
-
if subcommand == "init":
|
|
195
|
-
print(f"{Colors.BLUE}🔧 Initializing new project...{Colors.END}")
|
|
196
|
-
time.sleep(1)
|
|
197
|
-
print(f"{Colors.GREEN}✅ Project initialized successfully!{Colors.END}")
|
|
198
|
-
|
|
199
|
-
elif subcommand == "run":
|
|
200
|
-
print(f"{Colors.GREEN}🏃 Running {command_name}...{Colors.END}")
|
|
201
|
-
time.sleep(1)
|
|
202
|
-
print(f"{Colors.CYAN}⚡ Processing...{Colors.END}")
|
|
203
|
-
time.sleep(1)
|
|
204
|
-
print(f"{Colors.GREEN}✅ Done!{Colors.END}")
|
|
205
|
-
|
|
206
|
-
elif subcommand == "config":
|
|
207
|
-
print(f"{Colors.YELLOW}⚙️ Current configuration:{Colors.END}")
|
|
208
|
-
print(f" • Mode: {Colors.GREEN}production{Colors.END}")
|
|
209
|
-
print(f" • Log Level: {Colors.GREEN}INFO{Colors.END}")
|
|
210
|
-
print(f" • Timeout: {Colors.GREEN}30s{Colors.END}")
|
|
211
|
-
|
|
212
|
-
elif subcommand == "login":
|
|
213
|
-
cmd_login()
|
|
214
|
-
|
|
215
|
-
elif subcommand == "logout":
|
|
216
|
-
cmd_logout()
|
|
217
|
-
|
|
218
|
-
elif subcommand == "status":
|
|
219
|
-
cmd_status()
|
|
220
|
-
|
|
221
|
-
elif subcommand == "shell":
|
|
222
|
-
interactive_shell()
|
|
223
|
-
|
|
224
|
-
elif subcommand == "version":
|
|
225
|
-
show_version()
|
|
226
|
-
|
|
227
|
-
else:
|
|
228
|
-
print(f"{Colors.RED}❌ Unknown subcommand: {subcommand}{Colors.END}")
|
|
229
|
-
print(f"{Colors.YELLOW}💡 Try: {command_name} --help{Colors.END}")
|
|
230
|
-
|
|
231
|
-
# ============ تابع اصلی ============
|
|
232
|
-
def main():
|
|
233
|
-
command_name = os.path.basename(sys.argv[0])
|
|
234
|
-
args = sys.argv[1:]
|
|
235
|
-
|
|
236
|
-
# بررسی آرگومانهای عمومی
|
|
237
|
-
if "--help" in args or "-h" in args:
|
|
238
|
-
show_help(command_name)
|
|
239
|
-
return
|
|
240
|
-
|
|
241
|
-
if "--version" in args or "-v" in args:
|
|
242
|
-
show_version()
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
# چاپ لوگو
|
|
246
|
-
print_logo(command_name)
|
|
247
|
-
time.sleep(0.3)
|
|
248
|
-
|
|
249
|
-
# دستور Star
|
|
250
|
-
if command_name == "Star":
|
|
251
|
-
star_coming_soon()
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
# حذف آرگومانهای عمومی
|
|
255
|
-
filtered_args = [arg for arg in args if arg not in ["--verbose"]]
|
|
256
|
-
|
|
257
|
-
if "--verbose" in args:
|
|
258
|
-
print(f"{Colors.CYAN}🔍 Verbose mode enabled{Colors.END}")
|
|
259
|
-
print(f"{Colors.YELLOW}📋 Command: {command_name}{Colors.END}")
|
|
260
|
-
print(f"{Colors.YELLOW}📋 Arguments: {filtered_args}{Colors.END}")
|
|
261
|
-
print()
|
|
262
|
-
|
|
263
|
-
# اجرای زیردستور
|
|
264
|
-
run_subcommand(command_name, filtered_args)
|
|
265
|
-
|
|
266
|
-
# خط جداکننده
|
|
267
|
-
print()
|
|
268
|
-
print(f"{Colors.BOLD}{Colors.BLUE}━" * 50 + f"{Colors.END}")
|
|
269
|
-
print(f"{Colors.CYAN}✨ Powered by pStar Engine v{VERSION}{Colors.END}")
|
|
270
|
-
|
|
271
|
-
if __name__ == "__main__":
|
|
272
|
-
try:
|
|
273
|
-
main()
|
|
274
|
-
except KeyboardInterrupt:
|
|
275
|
-
print(f"\n{Colors.YELLOW}⚠️ Interrupted by user. Goodbye!{Colors.END}")
|
|
276
|
-
sys.exit(0)
|
|
277
|
-
except Exception as e:
|
|
278
|
-
print(f"{Colors.RED}❌ Error: {e}{Colors.END}")
|
|
279
|
-
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
|