Skip to content

🚀 QuickSetup

Detects, installs, and initializes Composer in one step, returning a ready-to-use *Composer instance. It is the most convenient entry point.

When to use

Use this when you want to complete all environment preparation in a single line of code without manually assembling Options and calling EnsureInstalled. It is especially suited for the startup entry of scripts and CLI tools.

Signature

go
func QuickSetup(workingDir string, autoInstall bool) (*Composer, error)

Parameters

ParameterTypeDescription
workingDirstringThe working directory path; pass an empty string to use the current directory
autoInstallboolWhether to auto-install Composer when it is not detected

Return value

Return valueTypeDescription
First return value*ComposerThe ready Composer instance
Second return valueerrorReturned when construction or installation fails

Example

go
package main

import (
	"fmt"
	"log"

	"github.com/scagogogo/composer-skills/pkg/composer"
)

func main() {
	comp, err := composer.QuickSetup("/path/to/project", true)
	if err != nil {
		log.Fatalf("quick setup failed: %v", err)
	}
	fmt.Println("Composer environment ready ✅")
	// You can now use comp directly to perform various operations
}

Advanced

  • For an installation progress callback, use QuickSetupWithProgress.
  • For fine-grained control over each option, use New + DefaultOptions.
  • It internally calls EnsureInstalled, so with autoInstall=true it always ensures availability.

Released under the MIT License