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

Interactive output format #149

Merged
merged 22 commits into from
Aug 1, 2022
Merged

Conversation

digocorbellini
Copy link
Contributor

@digocorbellini digocorbellini commented Jul 28, 2022

Issue #, if available:

Description of changes:
Implemented a new CLI output format using the bubble tea tui. The new format includes a table with the same columns as the table-wide format and can be accessed through the interactive flag. The table can be resized both vertically and horizontally through resizing the terminal window and it supports vertical and horizontal scrolling.

The new output format lives in /selector/outputs/bubbletea.go.

The following bubble tea component was used to build the table: https://github.com/Evertras/bubble-table

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

bubble.tea.demo.mov

@digocorbellini digocorbellini requested a review from a team as a code owner July 28, 2022 18:03
@digocorbellini digocorbellini self-assigned this Jul 28, 2022
@bwagner5
Copy link
Contributor

NEAT!

@digocorbellini digocorbellini changed the title Intractable output format Interactive output format Jul 29, 2022
Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

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

nice work on this! A few comments on unifying the table-wide and interactive modes a little more so that we can keep these updated more easily.

pkg/selector/outputs/bubbletea.go Outdated Show resolved Hide resolved
pkg/selector/outputs/bubbletea.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
@bwagner5
Copy link
Contributor

Remember to hydrate the pricing caches w/ interactive mode just like with table-wide mode. Currently, if you clear your cache (--cache-ttl=0) and then run w/ interactive mode, all prices show -Not Fetched-

structType := reflect.TypeOf(columnDataStruct)
for i := 0; i < structType.NumField(); i++ {
columnHeader := structType.Field(i).Tag.Get(columnTag)
newCol := table.NewColumn(columnHeader, columnHeader, len(columnHeader)+headerPadding)
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that some columns are sized too small for the data (like CPU Arch and GPU Info). You should be able to dynamically calculate the columns header by looking for the max(row entry per column, column header, and some upper bound of column length).

@bwagner5
Copy link
Contributor

Just one comment on the column sizes and after that, lgtm! Nice job! I'll leave it to @AustinSiu for the final review, but no need to hold-up on my account.

Copy link
Contributor

@AustinSiu AustinSiu left a comment

Choose a reason for hiding this comment

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

Looks great, thank you very much for your hard work on this! Left some minor comments that can be addressed in other PRs (if at all), don't want to delay this any further. 👍

cmd/main.go Outdated Show resolved Hide resolved
gpus := int64(0)
gpuMemory := int64(0)
gpuType := []string{}
if instanceType.GpuInfo != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: when gpuInfo is nil because we have no gpus, wdyt about about having the default text be "none", "n/a", or etc. to match what we do with other "not present" cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will look into the reason why there was previously no default text for missing gpuInfo and then I will address it in my next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants