Skip to content

Commit 6c61563

Browse files
committed
run installer commands in mtc console
1 parent ea5e3ec commit 6c61563

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

mytonctrl/mytonctrl.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ def PreUp(local, ton):
249249

250250
def Installer(args):
251251
# args = ["python3", "/usr/src/mytonctrl/mytoninstaller.py"]
252-
args = ["python3", "-m", "mytoninstaller"]
253-
subprocess.run(args)
252+
cmd = ["python3", "-m", "mytoninstaller"]
253+
if args:
254+
cmd += ["-c", *args]
255+
subprocess.run(cmd)
254256
#end define
255257

256258

mytoninstaller/mytoninstaller.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,29 @@ def Event(local, name):
238238
#end define
239239

240240

241-
def General(local):
241+
def Command(local, args, console):
242+
cmd = args[0]
243+
args = args[1:]
244+
for item in console.menu_items:
245+
if cmd == item.cmd:
246+
console._try(item.func, args)
247+
print()
248+
local.exit()
249+
print(console.unknown_cmd)
250+
local.exit()
251+
#end define
252+
253+
254+
def General(local, console):
242255
if "-u" in sys.argv:
243256
ux = sys.argv.index("-u")
244257
user = sys.argv[ux+1]
245258
local.buffer.user = user
246259
Refresh(local)
260+
if "-c" in sys.argv:
261+
cx = sys.argv.index("-c")
262+
args = sys.argv[cx+1:]
263+
Command(local, args, console)
247264
if "-e" in sys.argv:
248265
ex = sys.argv.index("-e")
249266
name = sys.argv[ex+1]
@@ -282,7 +299,7 @@ def mytoninstaller():
282299

283300
Init(local, console)
284301
if len(sys.argv) > 1:
285-
General(local)
302+
General(local, console)
286303
else:
287304
console.Run()
288305
local.exit()

0 commit comments

Comments
 (0)