~welt/murse

59f92316d7cddc56a5c909354f64e57b1664ced6 — welt 5 months ago 0bddb9c v0.0.3
Move some command descriptions to constants, fix marshaler for realsies, and stop being anal about slashes.
5 files changed, 27 insertions(+), 9 deletions(-)

M const.go
M main.go
M upgrade.go
M verify.go
M versioning.go
M const.go => const.go +9 -1
@@ 1,3 1,11 @@
package main

const VERSION = "0.0.2"
const VERSION = "0.0.3"

const (
	DESC_UPGRADE = "Upgrades your game files to the latest version."
	DESC_HTTP2   = "Enables HTTP/2, may cause problems with the servers but is faster."
	DESC_REPO    = "URL of the TVS repository."
	DESC_FILES   = "Directory of game files."
	DESC_DRY     = "Runs the command, but doesn't write any changes."
)

M main.go => main.go +7 -7
@@ 15,19 15,19 @@ func main() {
	var repair bool

	upgrade := flaggy.NewSubcommand("upgrade")
	upgrade.Description = "Upgrades your game files to the latest version."
	upgrade.String(&url, "u", "url", "URL of TVS repository with a slash at the end.")
	upgrade.Description = DESC_UPGRADE
	upgrade.String(&url, "u", "url", DESC_REPO)
	upgrade.Int(&threads, "c", "threads", "Number of threads to use for downloading, minimum two.")
	upgrade.Bool(&http2, "2", "http2", "Enables HTTP/2, may cause problems with the servers but is faster.")
	upgrade.AddPositionalValue(&dir, "directory", 1, true, "Directory of game files.")
	upgrade.Bool(&http2, "2", "http2", DESC_HTTP2)
	upgrade.AddPositionalValue(&dir, "directory", 1, true, DESC_FILES)
	flaggy.AttachSubcommand(upgrade, 1)

	verify := flaggy.NewSubcommand("verify")
	verify.Description = "Verifies an installation's files."
	verify.AddPositionalValue(&dir, "directory", 1, true, "Directory of game files.")
	verify.String(&url, "u", "url", "URL of TVS repository with a slash at the end.")
	verify.String(&url, "u", "url", DESC_REPO)
	verify.Bool(&repair, "r", "repair", "Repair the files where problems are found automatically.")
	verify.Bool(&http2, "2", "http2", "Enables HTTP/2, may cause problems with the servers but is faster.")
	verify.Bool(&http2, "2", "http2", DESC_HTTP2)
	flaggy.AttachSubcommand(verify, 1)

	var tvsdir string


@@ 35,7 35,7 @@ func main() {
	toast.Description = "Toasts files. Don't use this unless you know what you're doing."
	toast.AddPositionalValue(&dir, "game files", 1, true, "Directory of game files to reference.")
	toast.AddPositionalValue(&tvsdir, "tvs directory", 2, true, "Directory of TVS folder to add changes to.")
	toast.Bool(&dry, "d", "dry", "Runs the command, but doesn't write any changes.")
	toast.Bool(&dry, "d", "dry", DESC_DRY)
	flaggy.AttachSubcommand(toast, 1)

	flaggy.SetVersion(VERSION)

M upgrade.go => upgrade.go +5 -0
@@ 7,9 7,14 @@ import (
	"path/filepath"
	"runtime/debug"
	"strconv"
	"strings"
)

func upgradeMain(dir string, url string, threads int, http2 bool) int {
	if !strings.HasSuffix(url, "/") {
		url = url + "/"
	}

	instRev, err := getInstalledRevision(dir)
	if err != nil {
		errPrintln(err)

M verify.go => verify.go +5 -0
@@ 7,9 7,14 @@ import (
	"io"
	"os"
	"path/filepath"
	"strings"
)

func verifyMain(dir string, url string, repair bool, http2 bool) int {
	if !strings.HasSuffix(url, "/") {
		url = url + "/"
	}

	instRev, err := getInstalledRevision(dir)
	if err != nil {
		errPrintln(err)

M versioning.go => versioning.go +1 -1
@@ 22,7 22,7 @@ func (c *Change) MarshalJSON() ([]byte, error) {
		return json.Marshal(map[string]interface{}{
			"type":   c.Type,
			"path":   c.Path,
			"md5":    c.MD5,
			"hash":   c.MD5,
			"object": c.Object,
		})
	}