tapestry-cloud / tapestry

PHP static site generator using the plates template system
https://www.tapestry.cloud/
MIT License
32 stars 1 forks source link

[2.0] Refactor Commands #281

Open carbontwelve opened 6 years ago

carbontwelve commented 6 years ago

There are two commands that depend upon Tapestry to construct the Project class. To do so they both set the Input and Output for Tapestry and validate it. This isn't a problem given that neither code paths will ever be executed in the same cycle - however the duplicate code bothers me.

The shared code needs placing in once place:

        try {
            $this->tapestry->setInput($this->input);
            $this->tapestry->setOutput($this->output);
            $this->tapestry->validateInput();
        } catch (InvalidConsoleInputException $e) {
            $this->output->writeln('<error>[!]</error> '.$e->getMessage().' Doing nothing and exiting.');
            return 1;
        }

The very fact that this code is duplicated means that the way Tapestry works with relation to the command line is overly complex and requires a refactor.

The Tapestry class is both the Container and application, while the cli Application is separate. I feel that this also requires a refactor and is addressed in issue: #280