Skip to content

Commit 8537ae6

Browse files
committed
Merge remote-tracking branch 'origin/dev' into fix-approved-plugins
2 parents e55ed10 + 2773b9a commit 8537ae6

11 files changed

+77
-120
lines changed

Diff for: cmd/plugin/cmd.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import (
55
)
66

77
var PluginCmd = &cobra.Command{
8-
Use: "plugin",
8+
Use: "plugin",
9+
Short: "Manage plugins",
910
PreRunE: func(cmd *cobra.Command, args []string) error {
1011
return nil
1112
},

Diff for: cmd/predef/login.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
const RetrySleep = 3
1212

1313
var LoginCmd = &cobra.Command{
14-
Use: "login",
14+
Use: "login",
15+
Short: "Login to Kaytu",
1516
RunE: func(cmd *cobra.Command, args []string) error {
1617
cfg, err := server.GetConfig()
1718
if err != nil {

Diff for: cmd/predef/logout.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
)
77

88
var LogoutCmd = &cobra.Command{
9-
Use: "logout",
9+
Use: "logout",
10+
Short: "Logout from Kaytu",
1011
RunE: func(cmd *cobra.Command, args []string) error {
1112
err := server.RemoveConfig()
1213
if err != nil {

Diff for: cmd/predef/version.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99

1010
// VersionCmd represents the version command
1111
var VersionCmd = &cobra.Command{
12-
Use: "version",
12+
Use: "version",
13+
Short: "Print the version number of Kaytu CLI",
1314
Run: func(cmd *cobra.Command, args []string) {
1415
fmt.Println(version.VERSION)
1516
},

Diff for: cmd/root.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var optimizeCmd = &cobra.Command{
2525
RunE: func(cmd *cobra.Command, args []string) error {
2626
return cmd.Help()
2727
},
28+
Short: "Identify right sizing opportunities based on your usage",
29+
Long: "Identify right sizing opportunities based on your usage",
2830
}
2931

3032
// rootCmd represents the base command when called without any subcommands
@@ -89,8 +91,9 @@ func Execute() {
8991
for _, loopCmd := range plg.Config.Commands {
9092
cmd := loopCmd
9193
theCmd := &cobra.Command{
92-
Use: cmd.Name,
93-
Long: cmd.Description,
94+
Use: cmd.Name,
95+
Short: cmd.Description,
96+
Long: cmd.Description,
9497
RunE: func(c *cobra.Command, args []string) error {
9598
cfg, err := server.GetConfig()
9699
if err != nil {
@@ -218,11 +221,10 @@ func Execute() {
218221
return err
219222
} else {
220223
helpController := controller.NewHelp()
221-
helpPage := view.NewHelpPage(helpController)
222224

223225
jobsController := controller.NewJobs()
224226
statusBar := view.NewStatusBarView(jobsController, helpController)
225-
jobsPage := view.NewJobsPage(jobsController)
227+
jobsPage := view.NewJobsPage(jobsController, helpController, statusBar)
226228

227229
optimizationsController := controller.NewOptimizations()
228230
optimizationsPage := view.NewOptimizationsView(optimizationsController, helpController, statusBar)
@@ -235,7 +237,6 @@ func Execute() {
235237
optimizationsPage,
236238
optimizationsDetailsPage,
237239
preferencesPage,
238-
helpPage,
239240
jobsPage,
240241
), tea.WithFPS(10))
241242
if _, err := p.Run(); err != nil {

Diff for: view/app.go

+8-11
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import (
99
type PageEnum int
1010

1111
const (
12-
Page_Optimizations = 0
13-
Page_OptimizationDetails = 1
14-
Page_Preferences = 2
15-
Page_Help = 3
16-
Page_Jobs = 4
12+
Page_Overview = 0
13+
Page_ResourceDetails = 1
14+
Page_Preferences = 2
15+
Page_Jobs = 3
1716
)
1817

1918
type Page interface {
@@ -36,10 +35,9 @@ type App struct {
3635
}
3736

3837
func NewApp(
39-
optimizationsPage OptimizationsPage,
40-
optimizationDetailsPage OptimizationDetailsPage,
41-
preferencesPage PreferencesConfigurationPage,
42-
helpPage HelpPage,
38+
optimizationsPage OverviewPage,
39+
optimizationDetailsPage ResourceDetailsPage,
40+
preferencesPage PreferencesPage,
4341
jobsPage JobsPage,
4442
) *App {
4543
app := &App{}
@@ -49,7 +47,6 @@ func NewApp(
4947
optimizationsPage,
5048
optimizationDetailsPage,
5149
preferencesPage,
52-
helpPage,
5350
jobsPage,
5451
}
5552
return app
@@ -77,7 +74,7 @@ func (m *App) ChangePage(id PageEnum) tea.Cmd {
7774
}
7875

7976
func (m *App) Init() tea.Cmd {
80-
m.ChangePage(Page_Optimizations)
77+
m.ChangePage(Page_Overview)
8178
return tea.Batch(m.pages[m.activePageIdx].Init(), tea.EnterAltScreen, TickCmdWithDuration(100*time.Microsecond))
8279
}
8380

Diff for: view/page_help.go

-48
This file was deleted.

Diff for: view/page_jobs.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,39 @@ import (
1111
)
1212

1313
type JobsPage struct {
14-
jobController *controller.Jobs
14+
helpController *controller.Help
15+
jobController *controller.Jobs
16+
statusBar StatusBarView
1517

1618
responsive.ResponsiveView
1719
}
1820

19-
func NewJobsPage(jobController *controller.Jobs) JobsPage {
21+
func NewJobsPage(jobController *controller.Jobs, helpController *controller.Help, statusBar StatusBarView) JobsPage {
2022
return JobsPage{
21-
jobController: jobController,
23+
jobController: jobController,
24+
helpController: helpController,
25+
statusBar: statusBar,
2226
}
2327
}
2428

2529
func (m JobsPage) OnClose() Page {
2630
return m
2731
}
2832
func (m JobsPage) OnOpen() Page {
33+
m.helpController.SetKeyMap([]string{
34+
"esc: back to main menu",
35+
"q/ctrl+c: exit",
36+
})
37+
2938
return m
3039
}
3140

3241
func (m JobsPage) Init() tea.Cmd { return nil }
3342

3443
func (m JobsPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
44+
newStatusBar, _ := m.statusBar.Update(msg)
45+
m.statusBar = newStatusBar.(StatusBarView)
46+
3547
return m, nil
3648
}
3749

@@ -65,7 +77,8 @@ func (m JobsPage) View() string {
6577
lines = append(lines, " no running job")
6678
}
6779

68-
return "\n" + statusErr + strings.Join(lines, "\n")
80+
return "\n" + statusErr + strings.Join(lines, "\n") + "\n\n" +
81+
m.statusBar.View()
6982
}
7083
func (m JobsPage) SetResponsiveView(rv responsive.ResponsiveViewInterface) Page {
7184
m.ResponsiveView = rv.(responsive.ResponsiveView)

Diff for: view/page_optimization.go renamed to view/page_overview.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/kaytu-io/kaytu/view/responsive"
1111
)
1212

13-
type OptimizationsPage struct {
13+
type OverviewPage struct {
1414
table table.Model
1515
clearScreen bool
1616

@@ -26,7 +26,7 @@ func NewOptimizationsView(
2626
optimizations *controller.Optimizations,
2727
helpController *controller.Help,
2828
statusBar StatusBarView,
29-
) OptimizationsPage {
29+
) OverviewPage {
3030
columns := []table.Column{
3131
table.NewColumn("0", "Resource Id", 23),
3232
table.NewColumn("1", "Resource Name", 23),
@@ -44,17 +44,17 @@ func NewOptimizationsView(
4444
BorderRounded().
4545
HighlightStyle(style.HighlightStyle)
4646

47-
return OptimizationsPage{
47+
return OverviewPage{
4848
optimizations: optimizations,
4949
helpController: helpController,
5050
table: t,
5151
statusBar: statusBar,
5252
}
5353
}
54-
func (m OptimizationsPage) OnClose() Page {
54+
func (m OverviewPage) OnClose() Page {
5555
return m
5656
}
57-
func (m OptimizationsPage) OnOpen() Page {
57+
func (m OverviewPage) OnOpen() Page {
5858
m.helpController.SetKeyMap([]string{
5959
"↑/↓: move",
6060
"pgdown/pgup: next/prev page",
@@ -69,11 +69,11 @@ func (m OptimizationsPage) OnOpen() Page {
6969
return m
7070
}
7171

72-
func (m OptimizationsPage) Init() tea.Cmd {
72+
func (m OverviewPage) Init() tea.Cmd {
7373
return nil
7474
}
7575

76-
func (m OptimizationsPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
76+
func (m OverviewPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7777
var rows Rows
7878
for _, i := range m.optimizations.Items() {
7979
totalSaving := 0.0
@@ -168,7 +168,7 @@ func (m OptimizationsPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
168168
for _, i := range m.optimizations.Items() {
169169
if selectedInstanceID == i.Id && !i.Skipped && !i.Loading && !i.LazyLoadingEnabled {
170170
m.optimizations.SelectItem(i)
171-
changePageCmd = m.app.ChangePage(Page_OptimizationDetails)
171+
changePageCmd = m.app.ChangePage(Page_ResourceDetails)
172172
break
173173
} else if selectedInstanceID == i.Id && !i.Skipped && i.LazyLoadingEnabled {
174174
i.LazyLoadingEnabled = false
@@ -194,7 +194,7 @@ func (m OptimizationsPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
194194
return m, cmd
195195
}
196196

197-
func (m OptimizationsPage) View() string {
197+
func (m OverviewPage) View() string {
198198
//if m.clearScreen {
199199
// m.clearScreen = false
200200
// return ""
@@ -216,12 +216,12 @@ func (m OptimizationsPage) View() string {
216216
)
217217
}
218218

219-
func (m OptimizationsPage) SetApp(app *App) OptimizationsPage {
219+
func (m OverviewPage) SetApp(app *App) OverviewPage {
220220
m.app = app
221221
return m
222222
}
223223

224-
func (m OptimizationsPage) SetResponsiveView(rv responsive.ResponsiveViewInterface) Page {
224+
func (m OverviewPage) SetResponsiveView(rv responsive.ResponsiveViewInterface) Page {
225225
m.ResponsiveView = rv.(responsive.ResponsiveView)
226226
return m
227227
}

0 commit comments

Comments
 (0)