Add prefix options for the status command

This commit is contained in:
Alvaro Muñoz
2023-07-06 16:27:27 +02:00
parent 65b6eff68a
commit 402cb36db9
4 changed files with 126 additions and 77 deletions

View File

@@ -71,6 +71,22 @@ func LoadSession(name string) (string, []models.Run, string, error) {
return "", nil, "", errors.New("No session found for " + name)
}
func GetSessionsStartingWith(prefix string) ([]string, error) {
sessions, err := GetSessions()
if err != nil {
return nil, err
}
var matchingSessions []string
if sessions != nil {
for session := range sessions {
if strings.HasPrefix(session, prefix) {
matchingSessions = append(matchingSessions, session)
}
}
}
return matchingSessions, nil
}
func GetRunDetails(controller string, runId int) (map[string]interface{}, error) {
opts := api.ClientOptions{
Headers: map[string]string{"Accept": "application/vnd.github.v3+json"},