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

Improve ftl status output readability #456

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/ftl/cmd_ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (s *psCmd) Run(ctx context.Context, client ftlv1connect.ControllerServiceCl
return errors.WithStack(err)
}
if s.JSON {
marshaller := jsonpb.Marshaler{}
marshaller := jsonpb.Marshaler{Indent: " "}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one makes sense, but the other two shouldn't be indented, as they're part of a columnar output and indenting them will just corrupt the columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah cool, fixed

for _, process := range status.Msg.Processes {
err = marshaller.Marshal(os.Stdout, process)
if err != nil {
Expand Down Expand Up @@ -66,15 +66,15 @@ func (s *psCmd) Run(ctx context.Context, client ftlv1connect.ControllerServiceCl
key = fmt.Sprintf("%s-%s", key, strings.ToLower(runner.Key[len(runner.Key)-5:]))
runnerKey = runner.Key
endpoint = runner.Endpoint
labels, err := (&jsonpb.Marshaler{}).MarshalToString(runner.Labels)
labels, err := (&jsonpb.Marshaler{Indent: " "}).MarshalToString(runner.Labels)
if err != nil {
return errors.WithStack(err)
}
runnerLabels = labels
}
args := []any{key, fmt.Sprintf("%d/%d", i+1, first.MinReplicas), "live", runnerKey, endpoint}
if s.Verbose > 1 {
labels, err := (&jsonpb.Marshaler{}).MarshalToString(first.Labels)
labels, err := (&jsonpb.Marshaler{Indent: " "}).MarshalToString(first.Labels)
if err != nil {
return errors.WithStack(err)
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/ftl/cmd_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ func (s *statusCmd) Run(ctx context.Context, client ftlv1connect.ControllerServi
deployment.Schema = nil
}
}
return errors.WithStack((&jsonpb.Marshaler{}).Marshal(os.Stdout, status.Msg))
return errors.WithStack((&jsonpb.Marshaler{
Indent: " ",
}).Marshal(os.Stdout, status.Msg))
}