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

Follow conventions for Conan 2.0 CLI output #12235

Merged
merged 15 commits into from
Oct 5, 2022

Conversation

czoido
Copy link
Contributor

@czoido czoido commented Oct 4, 2022

Still working on it ...

Following the convention for Conan 2.0 that the results for the commands are dumped to the stdout. Rest of operations while running the command are dumped to stderr.

Several fixes in the output for the CLI:

  • All commands must define a text formatter if they have to output something to the stdout.
  • The text formatter is not shown in the help and is used by default in case the command defined it.

I think that the formatters were not correctly used in the code because they only formatted the output and not write anything and maybe that was a bit confusing, so now the formatters are changed to also do the actual output to stdout using cli_out_write()

@czoido czoido changed the title Correct cli output Follow conventions for Conan 2.0 CLI output Oct 4, 2022
@czoido czoido added this to the 2.0.0-beta4 milestone Oct 4, 2022
@czoido czoido marked this pull request as draft October 4, 2022 07:32
@czoido czoido changed the title Follow conventions for Conan 2.0 CLI output [WIP] Follow conventions for Conan 2.0 CLI output Oct 4, 2022
conan/cli/commands/inspect.py Outdated Show resolved Hide resolved
@czoido czoido closed this Oct 5, 2022
@czoido czoido reopened this Oct 5, 2022
@czoido czoido marked this pull request as ready for review October 5, 2022 10:23
@czoido czoido requested a review from memsharded October 5, 2022 10:24
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to discuss some approaches

myjson = json.dumps(data, indent=4, cls=ConanJSONEncoder)
return myjson
ConanOutput(stream=sys.stdout).writeln(myjson)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this. We were discussing about how ConanOutput was always for our messages to stderr, while we would use other things for stdout. Becaye also there is extra configurations, like loggers or the logger-as-json that can affect how the ConanOutput behaves, and that would be bad for the stdout output, wouldn't it?

Copy link
Contributor Author

@czoido czoido Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see, then probably what needs to be used is cli_out_write (we can change the name later perhaps), I'll make the changes and we see from there

conan/cli/command.py Show resolved Hide resolved
conan/cli/commands/cache.py Show resolved Hide resolved
@czoido czoido changed the title [WIP] Follow conventions for Conan 2.0 CLI output Follow conventions for Conan 2.0 CLI output Oct 5, 2022
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job

@memsharded memsharded merged commit 6f8f9c5 into conan-io:develop2 Oct 5, 2022
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

Successfully merging this pull request may close these issues.

2 participants