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

composer-json argument needs unused command to be passed #607

Open
icanhazstring opened this issue Dec 30, 2023 · 1 comment
Open

composer-json argument needs unused command to be passed #607

icanhazstring opened this issue Dec 30, 2023 · 1 comment

Comments

@icanhazstring
Copy link
Member

Describe the bug

Trying to use composer-unused on a global binary and passing along a certain composer.json has a really awkward usage.

You have to use:

composer-unused.phar unused <path-to-composer.json>

The unused command name should not be present at all.
This is due to the "multi command" console application.

https://github.com/composer-unused/composer-unused/blob/main/bin/composer-unused#L60-L64
Maybe there is a better way to do that.

@MarcinGladkowski
Copy link
Contributor

MarcinGladkowski commented Jan 5, 2024

Hi!

PR: #608

In my opinion this is happen because of limitation of implementation default command in symfony/console
https://github.com/symfony/console/blob/f8587c4cdc5acad67af71c37db34ef03af91e59c/Application.php#L1193-L1204

My idea to resolve it is:

  • while any of rest of commands aren't used as first argument, I mean
    debug:consumed-symbols or 'debug:provided-symbols' the package treats unused command as default single command.
$application->setDefaultCommand('unused', true);

That change behaviour from

./bin/composer-unused composer.json         
Command "composer.json" is not defined.                                            

To:

Results
-------

Found 17 used, 0 unused, 0 ignored and 1 zombie packages

But while using other commands is still works as expected:

./bin/composer-unused debug:consumed-symbols                                                                                       1 err | system node | 
ArrayIterator
Closure
// ...

Testing:
I'm testing it with generating phar locally, but write PHPunit integration tests is quite not conventional. I cannot easily get output even using buffer.

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