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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pStar-cli
3
- Version: 1.0.2
3
+ Version: 1.0.3
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.2
3
+ Version: 1.0.3
4
4
  Summary: A powerful CLI tool with multiple commands
5
5
  Home-page: https://github.com/Findlo/pustil
6
6
  Author: Eliot Sterling
@@ -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.1.0"
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} 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")
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} 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")
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
- """اجرای زیردستورات (init, run, config و ...)"""
180
+ """اجرای زیردستورات"""
96
181
  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}")
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
- # پردازش آرگومان‌های کلی (--help, --version)
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
- # نمایش لوگو با تاخیر 0.3 ثانیه برای جلوه‌ی بهتر
245
+ # چاپ لوگو
147
246
  print_logo(command_name)
148
247
  time.sleep(0.3)
149
248
 
150
- # اگر دستور Star باشه، پیام ویژه
249
+ # دستور Star
151
250
  if command_name == "Star":
152
251
  star_coming_soon()
153
252
  return
154
253
 
155
- # پردازش بقیه دستورات (Pustil, PStar, PStar-cli)
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()
@@ -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.2",
8
+ version="1.0.3",
9
9
  author="Eliot Sterling",
10
10
  author_email="itseliot0x@gmail.com",
11
11
  description="A powerful CLI tool with multiple commands",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes