cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] inconsistent uses of `-o` flag in some commands

Open Adi-204 opened this issue 10 months ago • 4 comments

Describe the bug.

In some commands like asyncapi bundle, asyncapi format etc the -o flag is written explicitly in flags file while in below 3 commands it is used from validationFlags() . According to the code the output flag inside validationFlags() is responsible to write any diagnostics (if present) in file but the description of this flag is - 'The output file name. Omitting this flag the result will be printed in the console.' which might confuse user with other commands output flags.

  1. asyncapi diff OLD NEW - In this command we have 2 flags with -o -o, --output= The output file name. Omitting this flag the result will be printed in the console. -o, --overrides= path to JSON file containing the override properties

Case 1 - Write only -o

Image

It is assuming that I am trying to use --overrides

Case 2 - Provide --output as flag

Image

It is printing correct output in logs but no file was created.

  1. asyncapi validate [SPEC-FILE] [PROXYHOST] [PROXYPORT] -
    In this command if we use -o flag than if their are any diagnostics than it will be printed in file otherwise file will be empty

Case 1 : Empty File

Image

Case 2: If Diagnostics present than shown in output

Image

So command is working fine but in documentation it is written: -o, --output= The output file name. Omitting this flag the result will be printed in the console. But about validation of file is still written in logs only because of logGovernanceMessage() in file src\core\parser.ts

  1. asyncapi generate models LANGUAGE FILE

The usage of -o flag in this command is working absolutely fine a folder is created and which contains model file.

Image

But this is created because of ModelinaFlags it also has output flag and was not created with help of validationFlags function.

Expected behavior

Solutions I am thinking to fix the issues -

  1. I think we should change field output inside validationFlags to output-diagnostics and flag from -o to --output-diagnostics so user dont get confuse.

  2. For asyncapi diff OLD NEW command we will have 3 flags --output-diagnostics for write diagnostics in file , -o for writing console print inside file and -O (maybe some other flag becuase all flags are in lowercase we can discuss) for override operation.

  3. For asyncapi validate [SPEC-FILE] [PROXYHOST] [PROXYPORT] command the output print in console is simple and we don't require it to copy in file so this command will have only --output-diagnostics flag (which is currently present with -o).

  4. For asyncapi generate models LANGUAGE FILE command -o is working correctly because of ModelinaFlags so if we just do above changes it will also have 2 different flags -o and --output-diagnostics.

Screenshots

Provided above.

How to Reproduce

Already mention above.

🥦 Browser

Google Chrome

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No

Adi-204 avatar Feb 09 '25 19:02 Adi-204

Waiting for issue approval by maintainers. Please assign me the issue.

Adi-204 avatar Feb 09 '25 19:02 Adi-204

Please explain me if I am missing something and understanding something wrong.

Adi-204 avatar Feb 09 '25 19:02 Adi-204

@AayushSaini101 Sir, any updates on this issue? I understand that you might be busy, but I believe this is a imp bug and need to be solve. Additionally, I would like to discuss potential options for the new override flag. Looking forward to your thoughts. thanks : )

Adi-204 avatar Feb 17 '25 07:02 Adi-204

Is this fixed? I still have the same issue in 3.1.1

lfvJonas avatar May 14 '25 08:05 lfvJonas

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Sep 14 '25 00:09 github-actions[bot]

Same issue with the diff command, when running the help command it says two options for -o

  -f, --format=<option>
      [default: yaml] format of the output
      <options: json|yaml|yml|md>

  -h, --help
      Show CLI help.

  -o, --output=<value>
      The output file name. Omitting this flag the result will be printed in the
      console.

  -o, --overrides=<value>
      path to JSON file containing the override properties

  -t, --type=<option>
      [default: all] type of the output
      <options: breaking|non-breaking|unclassified|all>

  -w, --watch
      Enable watch mode

  --diagnostics-format=<option>
      [default: stylish] format to use for validation diagnostics
      <options: json|stylish|junit|html|text|teamcity|pretty>

  --fail-severity=<option>
      [default: error] diagnostics of this level or above will trigger a failure
      exit code
      <options: error|warn|info|hint>

  --[no-]log-diagnostics
      log validation diagnostics or not

  --markdownSubtype=<option>
      the format of changes made to AsyncAPI document. It works only when diff is
      generated using md type. For example, when you specify subtype as json, then
      diff information in markdown is dumped as json structure.
      <options: json|yaml|yml>

  --no-error
      don't show error on breaking changes

DESCRIPTION
  Find diff between two asyncapi files

lfvJonas avatar Sep 15 '25 06:09 lfvJonas

Sorry for taking too long to circle back on this issue. Yes, this is a very important issue. Please go ahead with creating a PR @Adi-204.

Shurtu-gal avatar Sep 15 '25 10:09 Shurtu-gal

@Shurtu-gal I believe this is a very important issue. Unfortunately, I won’t be able to work on it over the next few days due to other commitments. It would be great if another contributor could take it up, or ideally, if one of the maintainers could address it, as I recall it being a bit complex. thanks :)

Adi-204 avatar Sep 15 '25 10:09 Adi-204

Unfortunately, I won’t be able to work on it over the next few days due to other commitments. It would be great if another contributor could take it up, or ideally, if one of the maintainers could address it, as I recall it being a bit complex. thanks :)

I can take this up @Shurtu-gal . No problem.

neoandmatrix avatar Sep 15 '25 10:09 neoandmatrix

Sure @neoandmatrix Thanks 🫂

Shurtu-gal avatar Sep 15 '25 12:09 Shurtu-gal

A possible name could be --config-overrides probably.

WDYT @AayushSaini101 @Souvikns ?

Shurtu-gal avatar Sep 15 '25 18:09 Shurtu-gal