pStar-cli 1.0.2__tar.gz → 1.0.3__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.3}/PKG-INFO +1 -1
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pStar_cli.egg-info/PKG-INFO +1 -1
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pustil/client.py +128 -31
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/setup.py +1 -1
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/MANIFEST.in +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/README.md +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pStar_cli.egg-info/SOURCES.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pStar_cli.egg-info/dependency_links.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pStar_cli.egg-info/entry_points.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pStar_cli.egg-info/top_level.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pustil/__init__.py +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/pustil/__main__.py +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/requirements.txt +0 -0
- {pstar_cli-1.0.2 → pstar_cli-1.0.3}/setup.cfg +0 -0
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import sys
|
|
5
5
|
import os
|
|
6
|
-
import argparse
|
|
7
6
|
import time
|
|
7
|
+
import getpass
|
|
8
|
+
import json
|
|
8
9
|
from datetime import datetime
|
|
10
|
+
from pathlib import Path
|
|
9
11
|
|
|
10
|
-
# ============ رنگهای ANSI
|
|
12
|
+
# ============ رنگهای ANSI ============
|
|
11
13
|
class Colors:
|
|
12
14
|
HEADER = '\033[95m'
|
|
13
15
|
BLUE = '\033[94m'
|
|
@@ -19,7 +21,7 @@ class Colors:
|
|
|
19
21
|
UNDERLINE = '\033[4m'
|
|
20
22
|
END = '\033[0m'
|
|
21
23
|
|
|
22
|
-
# ============
|
|
24
|
+
# ============ لوگوها ============
|
|
23
25
|
LOGOS = {
|
|
24
26
|
"Pustil": f"""
|
|
25
27
|
{Colors.CYAN}╔═══════════════════════════════════════╗
|
|
@@ -43,42 +45,63 @@ LOGOS = {
|
|
|
43
45
|
"""
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
VERSION = "1.
|
|
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()
|
|
47
70
|
|
|
48
71
|
# ============ توابع اصلی ============
|
|
49
72
|
def print_logo(command_name):
|
|
50
|
-
"""چاپ لوگوی مربوط به هر دستور"""
|
|
51
73
|
logo = LOGOS.get(command_name, LOGOS["Pustil"])
|
|
52
74
|
print(logo)
|
|
53
75
|
|
|
54
76
|
def show_help(command_name):
|
|
55
|
-
"""نمایش راهنمای هر دستور"""
|
|
56
77
|
print(f"{Colors.BOLD}{Colors.CYAN}📖 Help for {command_name}{Colors.END}")
|
|
57
78
|
print(f"{Colors.YELLOW}Usage:{Colors.END} {command_name} [OPTIONS] [COMMAND]")
|
|
58
79
|
print()
|
|
59
80
|
print(f"{Colors.GREEN}Commands:{Colors.END}")
|
|
60
|
-
print(f" {Colors.BOLD}init{Colors.END}
|
|
61
|
-
print(f" {Colors.BOLD}run{Colors.END}
|
|
62
|
-
print(f" {Colors.BOLD}config{Colors.END}
|
|
63
|
-
print(f" {Colors.BOLD}
|
|
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")
|
|
64
89
|
print()
|
|
65
90
|
print(f"{Colors.GREEN}Options:{Colors.END}")
|
|
66
|
-
print(f" {Colors.BOLD}--help{Colors.END}
|
|
67
|
-
print(f" {Colors.BOLD}--version{Colors.END}
|
|
68
|
-
print(f" {Colors.BOLD}--verbose{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")
|
|
69
94
|
print()
|
|
70
95
|
print(f"{Colors.YELLOW}Example:{Colors.END}")
|
|
96
|
+
print(f" {command_name} login")
|
|
71
97
|
print(f" {command_name} init --name MyProject")
|
|
72
|
-
print(f" {command_name} run --debug")
|
|
73
98
|
|
|
74
99
|
def show_version():
|
|
75
|
-
"""نمایش نسخه"""
|
|
76
100
|
print(f"{Colors.BOLD}{Colors.GREEN}pStar CLI v{VERSION}{Colors.END}")
|
|
77
101
|
print(f"{Colors.CYAN}Released: 2026-06-27{Colors.END}")
|
|
78
102
|
print(f"{Colors.YELLOW}✨ Built with ❤️ in Termux{Colors.END}")
|
|
79
103
|
|
|
80
104
|
def star_coming_soon():
|
|
81
|
-
"""نمایش پیام زیبا برای دستور Star"""
|
|
82
105
|
print(f"{Colors.RED}╔═════════════════════════════════════════════╗{Colors.END}")
|
|
83
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}")
|
|
84
107
|
print(f"{Colors.RED}╚═════════════════════════════════════════════╝{Colors.END}")
|
|
@@ -91,12 +114,79 @@ def star_coming_soon():
|
|
|
91
114
|
print()
|
|
92
115
|
print(f"{Colors.BOLD}{Colors.BLUE}✨ Follow us on GitHub for updates! ✨{Colors.END}")
|
|
93
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
|
+
|
|
94
179
|
def run_subcommand(command_name, args):
|
|
95
|
-
"""اجرای زیردستورات
|
|
180
|
+
"""اجرای زیردستورات"""
|
|
96
181
|
if len(args) == 0:
|
|
97
|
-
# بدون
|
|
98
|
-
|
|
99
|
-
|
|
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}")
|
|
100
190
|
return
|
|
101
191
|
|
|
102
192
|
subcommand = args[0]
|
|
@@ -119,6 +209,18 @@ def run_subcommand(command_name, args):
|
|
|
119
209
|
print(f" • Log Level: {Colors.GREEN}INFO{Colors.END}")
|
|
120
210
|
print(f" • Timeout: {Colors.GREEN}30s{Colors.END}")
|
|
121
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
|
+
|
|
122
224
|
elif subcommand == "version":
|
|
123
225
|
show_version()
|
|
124
226
|
|
|
@@ -128,13 +230,10 @@ def run_subcommand(command_name, args):
|
|
|
128
230
|
|
|
129
231
|
# ============ تابع اصلی ============
|
|
130
232
|
def main():
|
|
131
|
-
# تشخیص نام دستور
|
|
132
233
|
command_name = os.path.basename(sys.argv[0])
|
|
133
|
-
|
|
134
|
-
# حذف آرگومان اول (نام دستور) برای پردازش
|
|
135
234
|
args = sys.argv[1:]
|
|
136
235
|
|
|
137
|
-
#
|
|
236
|
+
# بررسی آرگومانهای عمومی
|
|
138
237
|
if "--help" in args or "-h" in args:
|
|
139
238
|
show_help(command_name)
|
|
140
239
|
return
|
|
@@ -143,17 +242,16 @@ def main():
|
|
|
143
242
|
show_version()
|
|
144
243
|
return
|
|
145
244
|
|
|
146
|
-
#
|
|
245
|
+
# چاپ لوگو
|
|
147
246
|
print_logo(command_name)
|
|
148
247
|
time.sleep(0.3)
|
|
149
248
|
|
|
150
|
-
#
|
|
249
|
+
# دستور Star
|
|
151
250
|
if command_name == "Star":
|
|
152
251
|
star_coming_soon()
|
|
153
252
|
return
|
|
154
253
|
|
|
155
|
-
#
|
|
156
|
-
# حذف آرگومانهای عمومی از لیست
|
|
254
|
+
# حذف آرگومانهای عمومی
|
|
157
255
|
filtered_args = [arg for arg in args if arg not in ["--verbose"]]
|
|
158
256
|
|
|
159
257
|
if "--verbose" in args:
|
|
@@ -162,15 +260,14 @@ def main():
|
|
|
162
260
|
print(f"{Colors.YELLOW}📋 Arguments: {filtered_args}{Colors.END}")
|
|
163
261
|
print()
|
|
164
262
|
|
|
165
|
-
# اجرای
|
|
263
|
+
# اجرای زیردستور
|
|
166
264
|
run_subcommand(command_name, filtered_args)
|
|
167
265
|
|
|
168
|
-
# خط جداکننده
|
|
266
|
+
# خط جداکننده
|
|
169
267
|
print()
|
|
170
268
|
print(f"{Colors.BOLD}{Colors.BLUE}━" * 50 + f"{Colors.END}")
|
|
171
269
|
print(f"{Colors.CYAN}✨ Powered by pStar Engine v{VERSION}{Colors.END}")
|
|
172
270
|
|
|
173
|
-
# ============ نقطهی ورود ============
|
|
174
271
|
if __name__ == "__main__":
|
|
175
272
|
try:
|
|
176
273
|
main()
|
|
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
|