func main() { profilesmanager.Register(example.New("i2", "eg")) profilescmdline.RegisterManagementCommands(commandLineDriver, true, "i2", jiri.ProfilesDBDir, jiri.ProfilesRootDir) tool.InitializeRunFlags(&commandLineDriver.Flags) cmdline.Main(commandLineDriver) }
func ExampleManager() { pdb := profiles.NewDB() myInstaller := "myProject" myProfile := "myNewProfile" profileName := profiles.QualifiedProfileName(myInstaller, myProfile) var target profiles.Target init := func() { mgr := newProfileMgr(myInstaller, myProfile) profilesmanager.Register(mgr) flags := flag.NewFlagSet("example", flag.ContinueOnError) profiles.RegisterTargetAndEnvFlags(flags, &target) flags.Parse([]string{"--target=arm-linux@1", "--env=A=B,C=D", "--env=E=F"}) } init() profileRoot := jiri.NewRelPath("profiles") mgr := profilesmanager.LookupManager(profileName) if mgr == nil { panic("manager not found for: " + profileName) } jirix := &jiri.X{Context: tool.NewDefaultContext()} // Install myNewProfile for target. if err := mgr.Install(jirix, pdb, profileRoot, target); err != nil { panic("failed to find manager for: " + profileName) } fmt.Println(mgr.String()) filename := tmpFile() defer os.RemoveAll(filepath.Dir(filename)) if err := pdb.Write(jirix, "test", filename); err != nil { panic(err) } // Start with a new profile data base. pdb = profiles.NewDB() // Read the profile database. pdb.Read(jirix, filename) mgr = profilesmanager.LookupManager(profileName) if mgr == nil { panic("manager not found for: " + profileName) } fmt.Println(mgr.String()) mgr.Uninstall(jirix, pdb, profileRoot, target) fmt.Println(mgr.String()) fmt.Println(mgr.VersionInfo().Supported()) fmt.Println(mgr.VersionInfo().Default()) // Output: // Profile: myNewProfile: installed // [arm-linux@1] // // Profile: myNewProfile: installed // [arm-linux@1] // // Profile: myNewProfile: not installed // // [4 3 2] // 3 }