Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Call on a Command that Uses Confirm Doesn't Work #333

Open
jcoughlin11 opened this issue Jun 21, 2023 · 0 comments
Open

Using Call on a Command that Uses Confirm Doesn't Work #333

jcoughlin11 opened this issue Jun 21, 2023 · 0 comments
Milestone

Comments

@jcoughlin11
Copy link

Hello! When using call from inside a command, if the command being called uses confirm, there's an error that says 'NoneType' object has no attribute 'readline'. It appears that this is because _stream is still None in this case.

I'm using cleo v2.0.1. Here's a minimum working example:

import sys

from cleo.application import Application as BaseApplication
from cleo.commands.command import Command as BaseCommand
from cleo.helpers import argument


class FirstCommand(BaseCommand):
    name = "first cmd"
    description = "Stuff"
    help = "Stuff"
    arguments = [argument("firstArg", "First argument.")]

    def handle(self) -> int:
        self.call("second cmd", f"PLACEHOLDER {self.argument('firstArg')}")

        return 0


class SecondCommand(BaseCommand):
    name = "second cmd"
    description = "Stuff"
    help = "Stuff"
    arguments = [argument("secondArg", "Second argument.")]

    def handle(self) -> int:
        self.line(f"Arg = {self.argument('secondArg')}")
        if not self.confirm("Proceed?"):
            self.line("Quitting")
            sys.exit(1)

        return 0


class Application(BaseApplication):
    def __init__(self) -> None:
        super().__init__()
        self.add(FirstCommand())
        self.add(SecondCommand())


if __name__ == "__main__":
    Application().run()

and then running via python3 ./main.py first cmd 42

The use of PLACEHOLDER is because of this isue.

@Secrus Secrus added this to the Future milestone Jul 7, 2023
@Secrus Secrus modified the milestones: Future, 3.0 Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants