You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to achieve this by setting multiple=True, like this script for instance:
#myprogram.py
from cleo.application import Application
from cleo.commands.command import Command
from cleo.helpers import argument
class RunCommand(Command):
name = "run"
description = "Runs a command in the appropriate environment."
arguments = [
argument("args", "The command and arguments/options to run.", multiple=True)
]
def handle(self):
args = self.argument("args")
print(args)
if __name__ == "__main__":
application = Application()
application.add(RunCommand())
application.run()
When running python myprogram.py run target --var1 1 --var2 10, cleo would throw an error about --var1 option does not exist. Upon futher looking, poetry seems to achieve this by subclassing Application, and redefining io. I am just wondering if there is a painless way of doing this natively in cleo. I am happy to contribute if this feature is not yet available.
Edit:
I know that this can be achieved by using raw sys.argv, but I want to use cleo features like help and list.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I tried to achieve this by setting
multiple=True
, like this script for instance:When running
python myprogram.py run target --var1 1 --var2 10
, cleo would throw an error about--var1
option does not exist. Upon futher looking,poetry
seems to achieve this by subclassingApplication
, and redefiningio
. I am just wondering if there is a painless way of doing this natively incleo
. I am happy to contribute if this feature is not yet available.Edit:
I know that this can be achieved by using raw
sys.argv
, but I want to usecleo
features likehelp
andlist
.Beta Was this translation helpful? Give feedback.
All reactions