cmd/stepd: List all loaded providers on startup
This commit is contained in:
		
							parent
							
								
									ab167234d0
								
							
						
					
					
						commit
						9a6607494f
					
				@ -8,6 +8,7 @@ import "slices"
 | 
			
		||||
import "errors"
 | 
			
		||||
import "context"
 | 
			
		||||
import "net/http"
 | 
			
		||||
import "unicode/utf8"
 | 
			
		||||
import "path/filepath"
 | 
			
		||||
import "git.tebibyte.media/sashakoshka/step"
 | 
			
		||||
import "git.tebibyte.media/sashakoshka/go-cli"
 | 
			
		||||
@ -114,6 +115,9 @@ func main () {
 | 
			
		||||
	err := environment.Init(context.Background())
 | 
			
		||||
	if err != nil { log.Fatal(err) }
 | 
			
		||||
 | 
			
		||||
	// TODO: load plugins
 | 
			
		||||
	logProviders(environment.Providers)
 | 
			
		||||
 | 
			
		||||
	// set up the HTTP handler
 | 
			
		||||
	handler := stephttp.Handler {
 | 
			
		||||
		Environment:       &environment,
 | 
			
		||||
@ -172,3 +176,27 @@ func (this *httpServerRoutine) Run (ctx context.Context) error {
 | 
			
		||||
	} 
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func logProviders (providers []step.Provider) {
 | 
			
		||||
	output := "providers: "
 | 
			
		||||
	x := utf8.RuneCountInString(output)
 | 
			
		||||
	for index, provider := range providers {
 | 
			
		||||
		packag := provider.Package()
 | 
			
		||||
		if index != len(providers) - 1 {
 | 
			
		||||
			packag += ", "
 | 
			
		||||
			x += 2
 | 
			
		||||
		}
 | 
			
		||||
		packageLen := utf8.RuneCountInString(packag)
 | 
			
		||||
		if x + packageLen >= 60 && output != "" {
 | 
			
		||||
			log.Println("(i)", output)
 | 
			
		||||
			output = ""
 | 
			
		||||
			x = 2
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		output += packag
 | 
			
		||||
		x += packageLen
 | 
			
		||||
	}
 | 
			
		||||
	if output != "" {
 | 
			
		||||
		log.Println("(i)", output)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user