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

[BREAKING] this change directly writes action reports to stdout #590

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
13 changes: 10 additions & 3 deletions cmd/action.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The NATS Authors
* Copyright 2018-2023 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -143,15 +143,22 @@ func run(ctx ActionCtx, action interface{}) error {

rs, err := e.Run(ctx)
if rs != nil {
ctx.CurrentCmd().Println(rs.Message())
if err := Write("--", []byte(rs.Message())); err != nil {
return err
}
sum, ok := rs.(store.Summarizer)
if ok {
m, err := sum.Summary()
if err != nil {
return err
}
if len(m) > 0 && !strings.HasSuffix(m, "\n") {
m = fmt.Sprintf("%s\n", m)
}
if m != "" {
ctx.CurrentCmd().Println(strings.TrimSuffix(m, "\n"))
if err := Write("--", []byte(m)); err != nil {
return err
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/generatenkey.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 The NATS Authors
* Copyright 2018-2023 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -152,7 +152,9 @@ func (p *GenerateNKeysParam) Run(ctx ActionCtx) (store.Status, error) {
return nil, err
}
}
ctx.CurrentCmd().Println(j.String(p.store))
if err := Write("--", []byte(j.String(p.store))); err != nil {
return nil, err
}
}
}
return nil, nil
Expand Down