pStar-cli 1.0.3__tar.gz → 1.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pStar-cli
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: A powerful CLI tool with multiple commands
5
5
  Home-page: https://github.com/Findlo/pustil
6
6
  Author: Eliot Sterling
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pStar-cli
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: A powerful CLI tool with multiple commands
5
5
  Home-page: https://github.com/Findlo/pustil
6
6
  Author: Eliot Sterling
@@ -0,0 +1,340 @@
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
+ import re
12
+ from pathlib import Path
13
+ from datetime import datetime
14
+
15
+ # ============ تنظیمات ============
16
+ BASE_DIR = Path.home() / "pustil-project"
17
+ USERS_DIR = BASE_DIR / "users"
18
+ ANIMATION_FILE = BASE_DIR / "animations" / "a.sh"
19
+ USRIDS_FILE = BASE_DIR / "usrids.json"
20
+ OWN_PASS_FILE = BASE_DIR / "own-pass.txt"
21
+ LOG_FILE = BASE_DIR / "activity.log"
22
+ SERVER_CONFIG_FILE = BASE_DIR / "server_config.json" # فایل جدید برای تنظیمات سرور
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.3.0"
37
+ SESSION = {} # {'username': str, 'logged_in': bool}
38
+
39
+ # ============ ابزارهای لاگ ============
40
+ def log_activity(username, action, details=""):
41
+ os.makedirs(LOG_FILE.parent, exist_ok=True)
42
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
43
+ with open(LOG_FILE, "a", encoding="utf-8") as f:
44
+ f.write(f"[{timestamp}] {username} - {action} {details}\n")
45
+
46
+ # ============ خواندن/نوشتن فایل‌ها ============
47
+ def load_json(file_path):
48
+ if file_path.exists():
49
+ with open(file_path, "r", encoding="utf-8") as f:
50
+ return json.load(f)
51
+ return {}
52
+
53
+ def save_json(file_path, data):
54
+ os.makedirs(file_path.parent, exist_ok=True)
55
+ with open(file_path, "w", encoding="utf-8") as f:
56
+ json.dump(data, f, indent=2, ensure_ascii=False)
57
+
58
+ def read_txt(file_path):
59
+ if file_path.exists():
60
+ with open(file_path, "r", encoding="utf-8") as f:
61
+ return f.read().strip()
62
+ return ""
63
+
64
+ # ============ انیمیشن ============
65
+ def play_animation():
66
+ if ANIMATION_FILE.exists():
67
+ try:
68
+ subprocess.run(["bash", str(ANIMATION_FILE)], check=False)
69
+ except:
70
+ pass
71
+ else:
72
+ print(f"{Colors.CYAN}🚀 Loading pStar...{Colors.END}")
73
+ for i in range(3):
74
+ print(f"{Colors.YELLOW}▪{'▪'*i}{Colors.END}", end="\r")
75
+ time.sleep(0.5)
76
+ print(f"{Colors.GREEN}✅ Ready!{Colors.END}")
77
+
78
+ # ============ احراز هویت ============
79
+ def authenticate(username, password):
80
+ users = load_json(USRIDS_FILE)
81
+ if username in users and users[username] == password:
82
+ return True
83
+ return False
84
+
85
+ def cmd_login():
86
+ play_animation()
87
+ print(f"{Colors.BOLD}{Colors.BLUE}┌─ pStar Login ──────────────────────┐{Colors.END}")
88
+ username = input(f"{Colors.CYAN}│ Enter Your DIO-USRID: {Colors.END}")
89
+ print(f"{Colors.GREEN}│ Welcome back {Colors.BOLD}{username}{Colors.END}{Colors.GREEN} !{Colors.END}")
90
+ password = getpass.getpass(f"{Colors.CYAN}│ Enter Password : {Colors.END}")
91
+ print(f"{Colors.BLUE}└──────────────────────────────────────┘{Colors.END}")
92
+
93
+ if authenticate(username, password):
94
+ SESSION['username'] = username
95
+ SESSION['logged_in'] = True
96
+ log_activity(username, "LOGIN", "Successful")
97
+ print(f"{Colors.GREEN}✅ Login successful!{Colors.END}")
98
+ return True
99
+ else:
100
+ log_activity(username, "LOGIN", "FAILED")
101
+ print(f"{Colors.RED}❌ Invalid username or password.{Colors.END}")
102
+ return False
103
+
104
+ def cmd_logout():
105
+ if SESSION.get('logged_in'):
106
+ username = SESSION['username']
107
+ SESSION.clear()
108
+ log_activity(username, "LOGOUT", "")
109
+ print(f"{Colors.GREEN}👋 Logged out.{Colors.END}")
110
+ return True
111
+ else:
112
+ print(f"{Colors.YELLOW}⚠️ Not logged in.{Colors.END}")
113
+ return False
114
+
115
+ def cmd_status():
116
+ if SESSION.get('logged_in'):
117
+ print(f"{Colors.GREEN}✅ Logged in as {Colors.BOLD}{SESSION['username']}{Colors.END}")
118
+ else:
119
+ print(f"{Colors.RED}❌ Not logged in.{Colors.END}")
120
+
121
+ # ============ set owner ============
122
+ def cmd_set_owner():
123
+ if not SESSION.get('logged_in'):
124
+ print(f"{Colors.RED}❌ Login first!{Colors.END}")
125
+ return
126
+ stored_hash = read_txt(OWN_PASS_FILE)
127
+ if not stored_hash:
128
+ print(f"{Colors.RED}❌ Owner password file missing!{Colors.END}")
129
+ return
130
+ if stored_hash.startswith("sha-256:"):
131
+ stored_hash = stored_hash.replace("sha-256:", "").strip()
132
+
133
+ entered = getpass.getpass(f"{Colors.CYAN}🔑 Enter 256-bit owner password: {Colors.END}")
134
+ entered_hash = hashlib.sha256(entered.encode()).hexdigest()
135
+ if entered_hash == stored_hash:
136
+ print(f"{Colors.GREEN}✅ Owner verified!{Colors.END}")
137
+ log_activity(SESSION['username'], "SET_OWNER", "Success")
138
+ else:
139
+ print(f"{Colors.RED}❌ Wrong password!{Colors.END}")
140
+ log_activity(SESSION['username'], "SET_OWNER", "FAILED")
141
+
142
+ # ============ search usr ============
143
+ def cmd_search(filename):
144
+ if not SESSION.get('logged_in'):
145
+ print(f"{Colors.RED}❌ Login first!{Colors.END}")
146
+ return
147
+ if not filename:
148
+ print(f"{Colors.YELLOW}Usage: search usr <filename>{Colors.END}")
149
+ return
150
+ if not filename.endswith(".txt"):
151
+ filename += ".txt"
152
+ target_file = USERS_DIR / filename
153
+ if not target_file.exists():
154
+ print(f"{Colors.RED}❌ File {filename} not found in users/{Colors.END}")
155
+ return
156
+ with open(target_file, "r", encoding="utf-8") as f:
157
+ content = f.read()
158
+ match = re.search(r'name\s*[:=]\s*["\']?([^"\'\n]+)["\']?', content, re.IGNORECASE)
159
+ if match:
160
+ name_value = match.group(1).strip()
161
+ print(f"{Colors.CYAN}📄 File: {filename}{Colors.END}")
162
+ print(f"{Colors.GREEN}👤 Name: {name_value}{Colors.END}")
163
+ else:
164
+ print(f"{Colors.YELLOW}⚠️ No 'name' field found.{Colors.END}")
165
+ fake_count = 92894913
166
+ print(f"{Colors.GREEN}✅ Found {fake_count:,} User{Colors.END}")
167
+ log_activity(SESSION['username'], "SEARCH", f"File: {filename}")
168
+
169
+ # ============ msg (placeholder) ============
170
+ def cmd_msg():
171
+ print(f"{Colors.YELLOW}💬 Msg feature is coming soon... Stay tuned!{Colors.END}")
172
+
173
+ # ============ شل تعاملی ✯> ============
174
+ def interactive_shell(first_run=False):
175
+ if not SESSION.get('logged_in'):
176
+ print(f"{Colors.RED}❌ You must login first. Run 'login'.{Colors.END}")
177
+ return
178
+
179
+ # اگه قبلاً توی شل هستیم، دوباره شل باز نکن
180
+ if hasattr(interactive_shell, "already_running") and interactive_shell.already_running:
181
+ print(f"{Colors.YELLOW}⚠️ Already in interactive shell.{Colors.END}")
182
+ return
183
+ interactive_shell.already_running = True
184
+
185
+ print(f"{Colors.BOLD}{Colors.CYAN}┌─ pStar Interactive Shell ───────────┐{Colors.END}")
186
+ print(f"{Colors.GREEN}│ Welcome {SESSION['username']}! Type 'help' │{Colors.END}")
187
+ print(f"{Colors.BLUE}└──────────────────────────────────────┘{Colors.END}")
188
+
189
+ while True:
190
+ try:
191
+ cmd_line = input(f"{Colors.YELLOW}✯>{Colors.END} ").strip()
192
+ if not cmd_line:
193
+ continue
194
+ parts = cmd_line.split()
195
+ command = parts[0].lower()
196
+ args = parts[1:]
197
+
198
+ # ===== دستورات =====
199
+ if command in ["exit", "quit"]:
200
+ print(f"{Colors.CYAN}👋 Goodbye!{Colors.END}")
201
+ interactive_shell.already_running = False
202
+ break
203
+
204
+ elif command == "help":
205
+ print(f"{Colors.GREEN}Available commands:{Colors.END}")
206
+ print(" login - Login to your account")
207
+ print(" logout - Logout (closes shell)")
208
+ print(" status - Show login status")
209
+ print(" set owner - Verify owner password")
210
+ print(" search usr <file> - Search user file")
211
+ print(" msg - Message feature (coming soon)")
212
+ print(" exit - Exit shell")
213
+ print(" help - Show this help")
214
+
215
+ elif command == "login":
216
+ if cmd_login():
217
+ # بعد از لاگین موفق، دوباره پرامپت نشون بده
218
+ pass
219
+
220
+ elif command == "logout":
221
+ if cmd_logout():
222
+ interactive_shell.already_running = False
223
+ break
224
+
225
+ elif command == "status":
226
+ cmd_status()
227
+
228
+ elif command == "set" and len(args) >= 1 and args[0] == "owner":
229
+ cmd_set_owner()
230
+ elif command == "set" and len(args) >= 1 and args[0] != "owner":
231
+ print(f"{Colors.RED}❌ Unknown subcommand: set {args[0]}{Colors.END}")
232
+ print(f"{Colors.YELLOW}💡 Use: set owner{Colors.END}")
233
+
234
+ elif command == "search" and len(args) >= 1 and args[0] == "usr":
235
+ # استخراج نام فایل (مابقی آرگومان‌ها)
236
+ filename = " ".join(args[1:]) if len(args) > 1 else ""
237
+ cmd_search(filename)
238
+ elif command == "search" and len(args) >= 1 and args[0] != "usr":
239
+ print(f"{Colors.RED}❌ Unknown search type: {args[0]}{Colors.END}")
240
+ print(f"{Colors.YELLOW}💡 Use: search usr <filename>{Colors.END}")
241
+
242
+ elif command == "msg":
243
+ cmd_msg()
244
+
245
+ elif command == "shell":
246
+ print(f"{Colors.YELLOW}⚠️ Already in shell.{Colors.END}")
247
+
248
+ else:
249
+ print(f"{Colors.RED}❌ Unknown command: {command}{Colors.END}")
250
+ print(f"{Colors.YELLOW}💡 Type 'help' for available commands.{Colors.END}")
251
+
252
+ except KeyboardInterrupt:
253
+ print(f"\n{Colors.CYAN}👋 Goodbye!{Colors.END}")
254
+ interactive_shell.already_running = False
255
+ break
256
+ except Exception as e:
257
+ print(f"{Colors.RED}❌ Error: {e}{Colors.END}")
258
+
259
+ interactive_shell.already_running = False
260
+
261
+ # ============ تابع اصلی (ورودی CLI) ============
262
+ def main():
263
+ command_name = os.path.basename(sys.argv[0])
264
+ args = sys.argv[1:]
265
+
266
+ if "--help" in args or "-h" in args:
267
+ show_help()
268
+ return
269
+ if "--version" in args or "-v" in args:
270
+ show_version()
271
+ return
272
+
273
+ # اگر هیچ آرگومانی نباشه => لاگین کن و شل باز کن
274
+ if len(args) == 0:
275
+ if not SESSION.get('logged_in'):
276
+ if not cmd_login():
277
+ return
278
+ interactive_shell(first_run=True)
279
+ return
280
+
281
+ # پردازش دستورات تک‌خطی
282
+ subcommand = args[0].lower()
283
+ rest_args = args[1:]
284
+
285
+ if subcommand == "login":
286
+ cmd_login()
287
+ elif subcommand == "logout":
288
+ cmd_logout()
289
+ elif subcommand == "status":
290
+ cmd_status()
291
+ elif subcommand == "set" and len(rest_args) >= 1 and rest_args[0] == "owner":
292
+ cmd_set_owner()
293
+ elif subcommand == "search" and len(rest_args) >= 2 and rest_args[0] == "usr":
294
+ filename = " ".join(rest_args[1:])
295
+ cmd_search(filename)
296
+ elif subcommand == "msg":
297
+ cmd_msg()
298
+ elif subcommand == "shell":
299
+ if not SESSION.get('logged_in'):
300
+ if not cmd_login():
301
+ return
302
+ interactive_shell()
303
+ else:
304
+ print(f"{Colors.RED}❌ Unknown command: {subcommand}{Colors.END}")
305
+ print(f"{Colors.YELLOW}💡 Try: pustil --help{Colors.END}")
306
+
307
+ def show_help():
308
+ print(f"{Colors.BOLD}{Colors.CYAN}📖 pStar CLI Help{Colors.END}")
309
+ print(f"{Colors.YELLOW}Usage:{Colors.END} pustil [COMMAND] [OPTIONS]")
310
+ print()
311
+ print(f"{Colors.GREEN}Commands:{Colors.END}")
312
+ print(" login - Login with animation")
313
+ print(" logout - Logout")
314
+ print(" status - Show login status")
315
+ print(" set owner - Verify owner password")
316
+ print(" search usr <file> - Search user TXT file")
317
+ print(" msg - Message feature (coming soon)")
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(" pustil login")
324
+ print(" pustil set owner")
325
+ print(" pustil search usr sample.txt")
326
+ print(" pustil 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
+
332
+ if __name__ == "__main__":
333
+ try:
334
+ main()
335
+ except KeyboardInterrupt:
336
+ print(f"\n{Colors.YELLOW}⚠️ Interrupted. Goodbye!{Colors.END}")
337
+ sys.exit(0)
338
+ except Exception as e:
339
+ print(f"{Colors.RED}❌ Error: {e}{Colors.END}")
340
+ sys.exit(1)
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="pStar-cli",
8
- version="1.0.3",
8
+ version="1.0.5",
9
9
  author="Eliot Sterling",
10
10
  author_email="itseliot0x@gmail.com",
11
11
  description="A powerful CLI tool with multiple commands",
@@ -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