Example #1
0
func TestManagerArgs(t *testing.T) {
	profilescmdline.Reset()
	p := parent
	profilescmdline.RegisterManagementCommands(&p, false, "", "", jiri.ProfilesRootDir)
	if got, want := len(p.Children), 6; got != want {
		t.Errorf("got %v, want %v", got, want)
	}
	type cl struct {
		args string
		n    int
	}
	cls := map[string]cl{
		"install":   cl{"--profiles-db=db --profiles-dir=root --target=arch-os --env=a=b,c=d --force=false", 5},
		"uninstall": cl{"--profiles-db=db --profiles-dir=root --target=arch-os --all-targets --v", 5},
		"cleanup":   cl{"--profiles-db=db --profiles-dir=root --gc --rm-all --v", 5},
		"update":    cl{"--profiles-db=db --profiles-dir=root -v", 3},
		"available": cl{"-v", 1},
	}
	for _, c := range p.Children {
		args := cls[c.Name].args
		if err := c.Flags.Parse(strings.Split(args, " ")); err != nil {
			t.Errorf("failed to parse for %s: %s: %v", c.Name, args, err)
			continue
		}
		if got, want := c.Flags.NFlag(), cls[c.Name].n; got != want {
			t.Errorf("%s: got %v, want %v", c.Name, got, want)
		}
	}
}
Example #2
0
func init() {
	profilescmdline.RegisterReaderCommands(cmdProfile, "", jiri.ProfilesDBDir)
	profilescmdline.RegisterManagementCommands(cmdProfile, true, "", jiri.ProfilesDBDir, jiri.ProfilesRootDir)
}
Example #3
0
func main() {
	profilesmanager.Register(example.New("i2", "eg"))
	profilescmdline.RegisterManagementCommands(commandLineDriver, true, "i2", jiri.ProfilesDBDir, jiri.ProfilesRootDir)
	tool.InitializeRunFlags(&commandLineDriver.Flags)
	cmdline.Main(commandLineDriver)
}