Skip to content

Commit

Permalink
fix kusion compile terminal output (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
markliby committed Jan 6, 2023
1 parent ff3be99 commit 5fa7704
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/kusionctl/cmd/compile/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func TestNewCmdCompile(t *testing.T) {
}, nil
},
)
monkey.Patch((*CompileOptions).Complete, func(o *CompileOptions, args []string) {
o.Output = "stdout"
})
defer monkey.UnpatchAll()

cmd := NewCmdCompile()
Expand Down
4 changes: 3 additions & 1 deletion pkg/kusionctl/cmd/compile/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type CompileFlags struct {
OverrideAST bool
}

const Stdout = "stdout"

func NewCompileOptions() *CompileOptions {
return &CompileOptions{
Filenames: []string{},
Expand Down Expand Up @@ -68,7 +70,7 @@ func (o *CompileOptions) Run() error {

// Output
yaml := compileResult.RawYAML()
if o.Output == "" {
if o.Output == Stdout {
fmt.Print(yaml)
} else {
if o.WorkDir != "" {
Expand Down

0 comments on commit 5fa7704

Please sign in to comment.