github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/singletons/session/session.go (about)

     1  package session
     2  
     3  import (
     4  	singletonsI18n "github.com/taubyte/tau-cli/i18n/singletons"
     5  
     6  	// Importing to run the common initialization
     7  	"github.com/taubyte/go-seer"
     8  	_ "github.com/taubyte/tau-cli/singletons/common"
     9  )
    10  
    11  func getOrCreateSession() *tauSession {
    12  	if _session == nil {
    13  		err := loadSession()
    14  		if err != nil {
    15  			panic(err)
    16  		}
    17  	}
    18  
    19  	return _session
    20  }
    21  
    22  func (s *tauSession) Document() *seer.Query {
    23  	return _session.root.Get(sessionFileName).Document().Fork()
    24  }
    25  
    26  func (s *tauSession) keys() (values []string, err error) {
    27  	values, err = _session.Document().List()
    28  	if err != nil {
    29  		err = singletonsI18n.SessionListFailed(err)
    30  	}
    31  
    32  	return
    33  }