~hristoast/wem

78f3236c13e030fe9718a404bfd6cd29f1dbd812 — Hristos N. Triantafillou 11 months ago b211f32 0.8.2
Add --info-date (#37)
3 files changed, 69 insertions(+), 0 deletions(-)

M cli/args.go
M cli/main_test.go
M cmd/completion.go
M cli/args.go => cli/args.go +5 -0
@@ 88,6 88,7 @@ type args struct {

	// Info args
	InfoDate string `arg:"--info-date" help:"Optional release date for this env's program"`
	InfoName string `arg:"--info-name" help:"The name of this env's program"`

	// InstallOpts args
	GogSilentInstall bool     `arg:"--gog-silent-install" help:"Pass flags to a GOG.com installer to silence as much output as possible"`


@@ 185,6 186,10 @@ func (a *args) applyArgs(e *env.WineEnv) {
		e.Info.Date = a.InfoDate
	}

	if a.InfoName != "" {
		e.Info.Name = a.InfoName
	}

	// InstallOpts
	if a.InstallArgs != nil {
		e.InstallOpts.InstallArgs = a.InstallArgs

M cli/main_test.go => cli/main_test.go +61 -0
@@ 669,6 669,67 @@ WinetricksPath = "/usr/bin/winetricks"
		}
	})

	// Changing the InfoName field should not change the name of the cfg file for the env
	t.Run("Cfg an env (change InfoName)", func(t *testing.T) {
		expected := fmt.Sprintf(`Saved: %s/.config/wem/TEST.cfg
`, dir)
		out, err := exe.QuickExe(wemExe, []string{
			"cfg", "TEST",
			"--info-date", "0000-00-00",
			"--info-name", "NEW NAME",
			"--run-exe", "hello-world.exe",
			"--run-workdir", "{{.WinePrefix}}/drive_c/wem-test",
			"--save",
			"--wine-exe", "/usr/bin/wine",
			"--wine-prefix", fmt.Sprintf("%s/TestPrefixDir", dir),
			"--winetricks-path", "/usr/bin/winetricks"}...)
		if err != nil {
			t.Errorf("Got an error: %s", err)
		}
		if !strings.HasSuffix(out, expected) {
			t.Errorf("got %s; expected: %s", out, expected)
		}

		expected = fmt.Sprintf(`Date = "0000-00-00"
DxvkVersion = ""
Esync = false
Fsync = false
GogSilentInstall = false
InstallArgs = []
InstallExe = ""
InstallExpected = ""
InstallWorkDir = ""
Name = "NEW NAME"
QuietRun = false
ReducePulseLatency = false
RestartPulse = false
RestoreResolution = false
RunArgs = []
RunExe = "hello-world.exe"
RunPost = ""
RunPre = ""
RunPrefix = ""
RunSuffix = ""
RunWorkDir = "%s/TestPrefixDir/drive_c/wem-test"
SingleCore = false
SysEnvVars = []
VirtualDesktop = ""
Vkd3dVersion = ""
VulkanIcdLoader = ""
WineArch = "win64"
WineArgs = []
WineDllOverrides = ""
WineExe = "/usr/bin/wine"
WinePrefix = "%s/TestPrefixDir"
WinetricksPath = "/usr/bin/winetricks"

`, dir, dir)
		out, _ = exe.QuickExe(wemExe, []string{"cfg", "TEST"}...)
		if out != expected {
			t.Errorf("got: %s; expected: %s", out, expected)
		}
	})

	// Clean everything up
	os.RemoveAll(dir)
}

M cmd/completion.go => cmd/completion.go +3 -0
@@ 168,6 168,9 @@ complete -c wem -n "__fish_seen_subcommand_from run" -l exec-args -x -d "Argumen
complete -c wem -n "__fish_seen_subcommand_from run" -l winecfg -x -d "Run winecfg with an env's context"
complete -c wem -n "__fish_seen_subcommand_from run" -l winetricks -x -d "Run winetricks with an env's context"

complete -c wem -n "__fish_seen_subcommand_from $cfgcmnds" -l info-date -x -d "Optional release date for this env's program"
complete -c wem -n "__fish_seen_subcommand_from $cfgcmnds" -l info-name -x -d "The name of this env's program"

complete -c wem -n "__fish_seen_subcommand_from $cfgcmnds" -l gog-silent-install -d "Pass flags to a GOG.com installer to silence as much output as possible"
complete -c wem -n "__fish_seen_subcommand_from $cfgcmnds" -l install-args -x -d "Additional arguments to use when running this env's install program"
complete -c wem -n "__fish_seen_subcommand_from $cfgcmnds" -l install-exe -x -d "The executable to run for installation"