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

refactor: Improve CLI output #122

Merged
merged 48 commits into from
Nov 29, 2023
Merged

refactor: Improve CLI output #122

merged 48 commits into from
Nov 29, 2023

Conversation

Techassi
Copy link
Member

@Techassi Techassi commented Oct 5, 2023

Fixes #59, part of #98, supersedes #55

This PR improves the CLI output for errors, progress and results. It tries to unify the complex output composition in a central place, which makes styling and formatting easier and subcommands don't need to re-implement common output patterns over and over again.

NOTE: This PR wanted to much all at once. That's why it only implements the error and general output improvements. Proper color (and NO_COLOR) and progress spinner support will be added in separate PRs.

@Techassi Techassi self-assigned this Oct 5, 2023
@Techassi Techassi marked this pull request as draft October 5, 2023 12:50
@Techassi

This comment was marked as outdated.

Copy link
Member

@nightkr nightkr left a comment

Choose a reason for hiding this comment

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

Haven't reviewed the rest, but a few things stood out to me

where
Self: std::error::Error,
{
fn into_error_report(self) -> std::result::Result<String, std::fmt::Error>;
Copy link
Member

Choose a reason for hiding this comment

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

This looks very similar to #[snafu::report]

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but there is no color output and not many other options to customize the output.

Copy link
Member

Choose a reason for hiding this comment

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

That's a lot of code for a very niche use case.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could maybe upstream some improvements, but I really want to have full control over the error output.

Copy link
Member

@NickLarsenNZ NickLarsenNZ Nov 27, 2023

Choose a reason for hiding this comment

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

Makes sense about the control/formatting. I think we should let this through, and if there's a way to do it via snafu::report, then we could do so in a future PR (shouldn't impact the end user).

rust/stackablectl/src/output/mod.rs Outdated Show resolved Hide resolved
@Techassi Techassi marked this pull request as ready for review October 20, 2023 11:32
Copy link
Member

@NickLarsenNZ NickLarsenNZ left a comment

Choose a reason for hiding this comment

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

Looking good. I left some comments, which were mostly caused by my lack of understanding.
Keen to go through each with you @Techassi - we can mark most of them as resolved without any change.

Cargo.toml Outdated Show resolved Hide resolved
rust/stackable-cockpit/src/common/list.rs Show resolved Hide resolved
rust/stackable-cockpit/src/common/list.rs Show resolved Hide resolved
rust/stackablectl/src/cmds/cache.rs Show resolved Hide resolved
rust/stackablectl/src/cmds/stacklet.rs Outdated Show resolved Hide resolved
rust/stackablectl/src/output/error.rs Outdated Show resolved Hide resolved
rust/stackablectl/src/output/mod.rs Show resolved Hide resolved
Copy link
Member

@maltesander maltesander left a comment

Choose a reason for hiding this comment

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

First part for me, did not really check or test the code yet.

Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
rust/stackable-cockpit/src/platform/credentials.rs Outdated Show resolved Hide resolved
rust/stackable-cockpit/src/platform/operator/mod.rs Outdated Show resolved Hide resolved
rust/stackable-cockpit/src/platform/service.rs Outdated Show resolved Hide resolved
rust/stackable-cockpit/src/platform/stack/spec.rs Outdated Show resolved Hide resolved
rust/stackable-cockpit/src/platform/operator/mod.rs Outdated Show resolved Hide resolved
rust/stackablectl/src/cmds/release.rs Outdated Show resolved Hide resolved
Copy link
Member

@NickLarsenNZ NickLarsenNZ left a comment

Choose a reason for hiding this comment

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

LGTM, just left one comment


#[snafu(display("no stdin error"))]
StdinError,
#[snafu(display("failed to start kind command"))]
Copy link
Member

Choose a reason for hiding this comment

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

Kind eventually needs to be in title case, but I wouldn't block the PR for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Will open a follow-up PR for that. Let's move for now.

@Techassi Techassi added this pull request to the merge queue Nov 29, 2023
Merged via the queue into main with commit 418986d Nov 29, 2023
42 checks passed
@Techassi Techassi deleted the feat/output branch November 29, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve error, progress and result output
5 participants