spectral icon indicating copy to clipboard operation
spectral copied to clipboard

PowerShell: Multiple Formater / Output does not work

Open LasneF opened this issue 1 year ago • 7 comments

Describe the bug the feature leveraging multiple formater / output is broken

To Reproduce

  • spectral lint openapi.yaml -r .spectral.yaml -f junit,html

returns Invalid values: Argument: format, Given: "junit html", Choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty", "github-actions", "sarif

notice i provided a coma , but the is mentionning a space

  • spectral lint openapi.yaml -r .spectral.yaml -f junit -f html -o a.junit -o a.html

return Multiple outputs have to be provided when more than a single format is specified

looks several -f is correctly interpreting as multiple formater , but not multiple output

  • spectral lint openapi.yaml -r .spectral.yaml -f junit -f html -o a.junit,a.html

Returns The number of outputs must match the number of formats

at the end i do not have found the right combination that make the multiple output working (target junit, html and stdout)

Expected behavior command line working like this

i can provide either -f junit,html or -f junit -f html , and same for output

documentation for the stdout output documentation with a basic sample with for instance stdout + a formater *

notice as well that in the simple case spectral lint openapi.yaml -r .spectral.yaml -f junit -o a.junit -q true

leveraging -q true or false as no impact , wheras i would expect it has (my target beeing output on stdout + html file)

**Environment ** spectral --version : 6.11.0

LasneF avatar Nov 15 '23 13:11 LasneF

+1

Invalid values:
  Argument: format, Given: "json,junit", Choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty", "github-actions", "sarif"

kiranpatel11 avatar Nov 23 '23 04:11 kiranpatel11

The documentation is incorrect. The command needs to be -f json -f text. We'll use this issue to update the docs.

mnaumanali94 avatar Jan 02 '24 15:01 mnaumanali94

Ran in the same issue. And also the documentation for multiple outputs (in combination with multiple formats) seems hard to understand

-o, --output                   where to output results, can be a single file name, multiple "output.<format>" or missing to print to stdout

For the part of "multiple "output."" it was not clear to me that this was referring to the output parameter itself and not the value that is passed with the parameter. Maybe an example in the documentation could help clear things up.

@LasneF a working command for your usecase would be

spectral lint openapi.yaml -r .spectral.yaml  -f junit -f html -o.junit a.xml -o.html a.html

quadrrem avatar Jan 12 '24 10:01 quadrrem

@P0lip are you sure it is only documentation ; the command line you provides does not work on my side

image

using spectral v6.11.0 running on windows

LasneF avatar Jan 17 '24 13:01 LasneF

@LasneF Could you try changing the shell to a Unix one like bash or zsh and see if it works? It might be possibly related to PowerShell - I don't know how it behaves there. There's a chance it gets parsed differently. I tried running a very similar command to yours and it completed just fine, but that's on Unix shell.

image

P0lip avatar Jan 17 '24 15:01 P0lip

@P0lip testing on Linux looks working , so this is a powershell topic , to me it deserve the bug to be re open , or to create a dedicated one on windows , as it is still a widely used platform

LasneF avatar Jan 24 '24 13:01 LasneF

@LasneF I'll follow up with that next week. I agree it's something we should at the very least document and offer a workaround.

P0lip avatar Feb 02 '24 11:02 P0lip