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

Fix new command. #1118

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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
2 changes: 1 addition & 1 deletion cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
"os"
"path/filepath"

"github.com/goccy/go-yaml"
"github.com/k1LoW/runn"
"github.com/k1LoW/runn/capture"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)

// newCmd represents the new command.
Expand Down
4 changes: 2 additions & 2 deletions cmdout.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (d *cmdOut) verboseOutResultForStep(idx int, sr *StepResult, path string, n
case sr.Err != nil:
// fail
lineformat := indent + " %s\n"
_, _ = fmt.Fprintf(d.out, "%s --- %s(%s) ... %s\n%s", indent, desc, sr.Key, red("fail"), red(SprintMultilinef(lineformat, "Failure/Error: %s", strings.TrimRight(sr.Err.Error(), "\n"))))
_, _ = fmt.Fprintf(d.out, "%s --- %s(%s) ... %s\n%s", indent, desc, sr.Key, red("fail"), red(sprintMultilinef(lineformat, "Failure/Error: %s", strings.TrimRight(sr.Err.Error(), "\n"))))
if len(sr.IncludedRunResults) > 0 {
for _, ir := range sr.IncludedRunResults {
_, _ = fmt.Fprintf(d.out, "%s === %s (%s)\n", indent, ir.Desc, ir.Path)
Expand All @@ -136,7 +136,7 @@ func (d *cmdOut) verboseOutResultForStep(idx int, sr *StepResult, path string, n
return
}
_, _ = fmt.Fprintf(d.out, "%s Failure step (%s):\n", indent, path)
_, _ = fmt.Fprint(d.out, SprintMultilinef(lineformat, "%v", picked))
_, _ = fmt.Fprint(d.out, sprintMultilinef(lineformat, "%v", picked))
_, _ = fmt.Fprintln(d.out, "")
case sr.Skipped:
// skip
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ require (
golang.org/x/sync v0.10.0
google.golang.org/grpc v1.69.0
google.golang.org/protobuf v1.35.2
gopkg.in/yaml.v2 v2.4.0
modernc.org/sqlite v1.34.2
)

Expand Down Expand Up @@ -208,6 +207,7 @@ require (
google.golang.org/genproto v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.55.3 // indirect
Expand Down
6 changes: 3 additions & 3 deletions result.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (rr *RunResult) outFailure(out io.Writer, index int) (int, error) {
for iii, pp := range p[1:] {
_, _ = fmt.Fprintf(out, " %s%s %s\n", strings.Repeat(" ", iii), tr, pp)
}
_, _ = fmt.Fprint(out, SprintMultilinef(" %s\n", "%v", red(fmt.Sprintf("Failure/Error: %s", strings.TrimRight(errs[ii].Error(), "\n")))))
_, _ = fmt.Fprint(out, sprintMultilinef(" %s\n", "%v", red(fmt.Sprintf("Failure/Error: %s", strings.TrimRight(errs[ii].Error(), "\n")))))

last := p[len(p)-1]
b, err := readFile(last)
Expand All @@ -208,7 +208,7 @@ func (rr *RunResult) outFailure(out io.Writer, index int) (int, error) {
return index, err
}
_, _ = fmt.Fprintf(out, " Failure step (%s):\n", normalizePath(last))
_, _ = fmt.Fprint(out, SprintMultilinef(" %s\n", "%v", picked))
_, _ = fmt.Fprint(out, sprintMultilinef(" %s\n", "%v", picked))
_, _ = fmt.Fprintln(out, "")
}

Expand Down Expand Up @@ -326,7 +326,7 @@ func simplifyStepResults(stepResults []*StepResult) []*stepResultSimplified {
return simplified
}

func SprintMultilinef(lineformat, format string, a ...any) string {
func sprintMultilinef(lineformat, format string, a ...any) string {
lines := strings.Split(fmt.Sprintf(format, a...), "\n")
var formatted string
for _, l := range lines {
Expand Down
7 changes: 2 additions & 5 deletions runbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,9 @@ func (rb *runbook) AppendStep(in ...string) error {
return rb.curlToStep(in...)
case strings.HasPrefix(in[0], "grpcurl"):
return rb.grpcurlToStep(in...)
case len(in) == 1:
return rb.axsLogToStep(in...)
default:
if len(in) == 1 {
if err := rb.axsLogToStep(in...); err == nil {
return nil
}
}
return rb.cmdToStep(in...)
}
}
Expand Down
3 changes: 2 additions & 1 deletion store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ const (

const (
storeStepKeyOutcome = "outcome"
storeFuncValue = "[func]"
)

// `runn` is global store for runn.
const (
storeRunnKeyKV = "kv"
storeRunnKeyRunNIndex = "i"
storeFuncValue = "[func]"
storeRunnKeyStdin = "stdin"
)

Expand Down
2 changes: 1 addition & 1 deletion test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func newCondFalseError(cond, tree string) *condFalseError {
}

func (fe *condFalseError) Error() string {
tree := SprintMultilinef(" %s\n", "%s", fe.tree)
tree := sprintMultilinef(" %s\n", "%s", fe.tree)
return fmt.Sprintf("condition is not true\n\nCondition:\n%s", tree)
}

Expand Down
Loading