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

option as-tree not working in command #54671

Open
r4cker opened this issue Apr 19, 2024 · 1 comment
Open

option as-tree not working in command #54671

r4cker opened this issue Apr 19, 2024 · 1 comment

Comments

@r4cker
Copy link

r4cker commented Apr 19, 2024

Symfony version(s) affected

6.4.4

Description

Hello,

I configured crowdin to import my translations but the as-tree is not working properly

php bin/console translation:pull crowdin --as-tree

I have to specify the following command to force the tree structure

php bin/console translation:pull loco --force --as-tree 1

How to reproduce

use the following console command

php bin/console translation:pull crowdin --as-tree

--as-tree is not taken in account

Possible Solution

I have to specify the following command to force the tree structure

php bin/console translation:pull loco --force --as-tree 1

Additional Context

in the file Symfony\Component\Translation\Command\TranslationPullCommand

The option is converted to an int

$asTree = (int) $input->getOption('as-tree');

but if the value is not an int it will not be taken in account

@stof
Copy link
Member

stof commented Apr 19, 2024

The implementation of translation:pull is indeed using lots of options with InputOption::VALUE_OPTIONAL without actually handling this properly (options where the value is optional are much harder to use to support them properly as you need to distinguish the case where they are not passed from the case where they are passed with no value).
Most of those options should not even use that flag but InputOption::VALUE_REQUIRED instead (for instance, passing --format without a value makes no sense).

Note that TranslationUpdateCommand suffers from the same issue about allowing --as-tree with no value but not supporting that case properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants