-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Extend the images CMD with the --tui
flag
#50
Changes from all commits
c972984
844a6a5
341094b
ccf1d07
05bf527
d0e4293
ea0b6b6
9f8d9b5
4dbf5e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ dist_mac_m1.zip | |
*.swp | ||
*.swo | ||
slim.report.json | ||
debug.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import ( | |
|
||
"github.com/mintoolkit/mint/pkg/app" | ||
"github.com/mintoolkit/mint/pkg/app/master/command" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui" | ||
"github.com/mintoolkit/mint/pkg/app/master/tui/models" | ||
"github.com/mintoolkit/mint/pkg/app/master/version" | ||
cmd "github.com/mintoolkit/mint/pkg/command" | ||
"github.com/mintoolkit/mint/pkg/crt" | ||
|
@@ -126,6 +128,11 @@ func OnCommand( | |
images, err := crtClient.ListImages(cparams.Filter) | ||
xc.FailOn(err) | ||
|
||
if cparams.TUI { | ||
model := models.InitialImages(images) | ||
tui.RunTUI(model) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will be good to term this into |
||
|
||
if xc.Out.Quiet { | ||
if xc.Out.OutputFormat == command.OutputFormatJSON { | ||
fmt.Printf("%s\n", jsonutil.ToPretty(images)) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package tui | ||
|
||
import ( | ||
"os" | ||
|
||
"log" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
// RunTUI starts the TUI program. | ||
func RunTUI(model tea.Model) { | ||
f, err := tea.LogToFile("debug.log", "debug") | ||
if err != nil { | ||
log.Printf("RunTUI Logging - %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
defer f.Close() | ||
|
||
p := tea.NewProgram(model) | ||
if _, err := p.Run(); err != nil { | ||
log.Printf("RunTUI error - %v", err) | ||
os.Exit(1) | ||
} | ||
} |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a bit of extra logic to configure
xc
beforeOnCommand
is called, so it knows it's executing in the TUI mode. That way thexc.Out.Info("cmd.input.params", ovars{ "runtime": rr, "filter": cparams.Filter, })
call earlier inOnCommand
won't print stuff to console.This snippet in
cli.go
for the command will need to be enhanced to know we are in the TUI mode:xc := app.NewExecutionContext( Name, gcvalues.QuietCLIMode, gcvalues.OutputFormat)