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

UnstructuredData does not apply --field option #1171

Open
ilyaukin opened this issue Dec 17, 2024 · 0 comments
Open

UnstructuredData does not apply --field option #1171

ilyaukin opened this issue Dec 17, 2024 · 0 comments

Comments

@ilyaukin
Copy link

Steps to reproduce

I have a command which returns UnstucturedData, something like

public function myCommand()
{
    return  new UnstructuredData(['id' => '123',....]);
}

Then I run robo my:command --field=id and I expect that I get exact id as string.

Expected behavior

I expect output 123.

Actual behavior

I see the error

 [error]  The format string cannot be used with the data produced by this command, which was an instance of Consolidation\OutputFormatters\StructuredData\UnstructuredData.  Valid formats are: csv,json,list,null,php,print-r,tsv,var_export,xml,yaml 

If I comment out these lines in FormatterManager.php

        if (!is_string($structuredOutput) && !$this->isValidFormat($formatter, $structuredOutput)) {
            $validFormats = $this->validFormats($structuredOutput);
            throw new InvalidFormatException((string)$format, $structuredOutput, $validFormats);
        }

I see the correct result...

System Configuration

OS: Debian GNU/Linux 12 (bookworm)
PHP 8.3.10
Robo 4.0.6

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

1 participant