mirror of
https://codeberg.org/gaschz/passff-host.git
synced 2025-06-06 18:08:46 +02:00
Separate positional from optional arguments
This commit is contained in:
parent
f8321af2d2
commit
c23d21b0a6
@ -50,22 +50,26 @@ def sendMessage(encodedMessage):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Read message from standard input
|
# Read message from standard input
|
||||||
receivedMessage = getMessage()
|
receivedMessage = getMessage()
|
||||||
args = []
|
opt_args = []
|
||||||
|
pos_args = []
|
||||||
stdin = None
|
stdin = None
|
||||||
|
|
||||||
if len(receivedMessage) == 0:
|
if len(receivedMessage) == 0:
|
||||||
pass
|
pass
|
||||||
elif receivedMessage[0] == "insert":
|
elif receivedMessage[0] == "insert":
|
||||||
args = ["insert", "-m", receivedMessage[1]]
|
opt_args = ["insert", "-m"]
|
||||||
|
pos_args = [receivedMessage[1]]
|
||||||
stdin = receivedMessage[2]
|
stdin = receivedMessage[2]
|
||||||
elif receivedMessage[0] == "generate":
|
elif receivedMessage[0] == "generate":
|
||||||
args = ["generate", receivedMessage[1], receivedMessage[2]]
|
pos_args = [receivedMessage[1], receivedMessage[2]]
|
||||||
if "-n" in receivedMessage:
|
opt_args = ["generate"]
|
||||||
args.append("-n")
|
if "-n" in receivedMessage[3:]:
|
||||||
|
opt_args.append("-n")
|
||||||
else:
|
else:
|
||||||
key = receivedMessage[0]
|
key = receivedMessage[0]
|
||||||
key = "/" + key if key[0] != "/" else key
|
key = "/" + (key[1:] if key[0] == "/" else key)
|
||||||
args.append(key)
|
pos_args = [key]
|
||||||
|
opt_args += commandArgs
|
||||||
|
|
||||||
# Set up (modified) command environment
|
# Set up (modified) command environment
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
@ -75,7 +79,7 @@ if __name__ == "__main__":
|
|||||||
env[key] = val
|
env[key] = val
|
||||||
|
|
||||||
# Set up subprocess params
|
# Set up subprocess params
|
||||||
cmd = [command] + args + commandArgs
|
cmd = [command] + opt_args + ['--'] + pos_args
|
||||||
proc_params = {
|
proc_params = {
|
||||||
'stdout': subprocess.PIPE,
|
'stdout': subprocess.PIPE,
|
||||||
'stderr': subprocess.PIPE,
|
'stderr': subprocess.PIPE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user