subtask: add list repository task

This commit is contained in:
oscarzhou 2022-12-26 20:55:06 +13:00
parent d3056fc0c9
commit 7f2afd1bdb
4 changed files with 37 additions and 1 deletions

1
go/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/test

View File

@ -18,6 +18,7 @@ func NewListDevToolCommandTask(cfg *configs.Config) *ListDevToolCommandTask {
func (task *ListDevToolCommandTask) Execute() error { func (task *ListDevToolCommandTask) Execute() error {
subTaskItems := []Tasker{ subTaskItems := []Tasker{
subtasks.NewListVolumeSubTask(task.Config), subtasks.NewListVolumeSubTask(task.Config),
subtasks.NewListRepositorySubTask(task.Config),
} }
ListCommandMenu(subTaskItems, "Which management commands do you want to choose:") ListCommandMenu(subTaskItems, "Which management commands do you want to choose:")

View File

@ -0,0 +1,34 @@
package subtasks
import (
"ocl/portainer-devtool/configs"
"ocl/portainer-devtool/utils"
"strings"
)
type ListRepositorySubTask struct {
Config *configs.Config
}
func NewListRepositorySubTask(cfg *configs.Config) *ListRepositorySubTask {
return &ListRepositorySubTask{
Config: cfg,
}
}
func (task *ListRepositorySubTask) Execute() error {
utils.InputPrint("Which repository?")
repositoryList := []string{" "}
for _, repo := range task.Config.RepositoryConfig {
repositoryList = append(repositoryList, repo.Name)
}
utils.SuccessPrint(strings.Join(repositoryList, "\n"))
return nil
}
func (task *ListRepositorySubTask) String() string {
return "List Repositories"
}

View File

@ -50,7 +50,7 @@ func (task *ListVolumeSubTask) Execute() error {
} }
func (task *ListVolumeSubTask) String() string { func (task *ListVolumeSubTask) String() string {
return "List Volume" return "List Volumes"
} }
func lenPath(path string) int { func lenPath(path string) int {