go(repositories): add sub menu for ee repository

pull/7/head
oscar 2022-08-21 21:34:10 +12:00
parent 5a6cd4ac16
commit b24dcfa9d9
2 changed files with 66 additions and 19 deletions

View File

@ -1,10 +1,10 @@
package main package main
import ( import (
"fmt"
"log" "log"
"ocl/portainer-devtool/repositories" "ocl/portainer-devtool/repositories"
"ocl/portainer-devtool/utils" "ocl/portainer-devtool/utils"
"os"
) )
const ( const (
@ -12,18 +12,24 @@ const (
MENU_OPTION_CE_REPO MENU_OPTION_CE_REPO
MENU_OPTION_AGENT_REPO MENU_OPTION_AGENT_REPO
MENU_OPTION_OTHERS MENU_OPTION_OTHERS
MENU_OPTION_QUIT
) )
func main() { func main() {
utils.MenuPrint() for {
var option int printMainMenu := func() {
_, err := fmt.Scanf("%d", &option) utils.MenuPrint("Which repository or action do you want to operate:", `
if err != nil { 1. Portainer EE Repository
log.Fatal(err) 2. Portainer CE Repository
3. Portainer Agent Repository
4. Others
5. Quit`)
} }
option := utils.PromptMenu(printMainMenu)
var action repositories.Actioner var action repositories.Actioner
switch option { switch option {
case MENU_OPTION_EE_REPO: case MENU_OPTION_EE_REPO:
@ -34,7 +40,14 @@ func main() {
case MENU_OPTION_OTHERS: case MENU_OPTION_OTHERS:
case MENU_OPTION_QUIT:
os.Exit(0)
}
err := action.Execute()
if err != nil {
log.Fatalln(err)
}
} }
log.Fatal(action.Execute())
} }

View File

@ -6,6 +6,18 @@ import (
"ocl/portainer-devtool/utils" "ocl/portainer-devtool/utils"
) )
const (
ACTION_EE_BUILD_ALL int = iota + 1
ACTION_EE_RUN_FRONTEND
ACTION_EE_RUN_BACKEND
ACTION_EE_VALIDATE_ALL
ACTION_EE_VALIDATE_FRONTEND
ACTION_EE_VALIDATE_BACKEND
ACTION_EE_RUN_UNIT_TEST_ALL
ACTION_EE_RUN_UNIT_TEST_FRONTEND
ACTION_EE_RUN_UNIT_TEST_BACKEND
)
type PortainerEE struct { type PortainerEE struct {
WorkDir string WorkDir string
FrontendDir string FrontendDir string
@ -33,5 +45,27 @@ func (repo *PortainerEE) Execute() error {
return nil return nil
} }
option := utils.PromptMenu(repo.listSubMenu)
switch option {
case ACTION_EE_BUILD_ALL:
case ACTION_EE_RUN_FRONTEND:
commands.RunPortainerClient(repo.WorkDir)
}
return nil return nil
} }
func (repo *PortainerEE) listSubMenu() {
utils.MenuPrint("Do you want?", `
1. Build both front-end and backend
2. Run front-end only
3. Run backend only
4. Validate both fornt-end and backend before commit
5. Validate front-end only before commit
6. Validate backend only before commit
7. Run unit tests for both front-end and backend
8. Run unit tests for front-end only
9. Run unit tests for backend only`)
}