diff --git a/.gitignore b/.gitignore index 0c18e51..8a86888 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -go.work -museum-digital-webdav-uploader +/go.work +/bin diff --git a/main.go b/main.go index 4ba9681..3c1d3d4 100644 --- a/main.go +++ b/main.go @@ -7,36 +7,12 @@ import ( "gitea.armuli.eu/museum-digital/museum-digital-webdav-uploader/src/webui" ) -// Attempts to connect to WebDAV server, verifying that the authentication data -// works and that the server is one for uploads with museum-digital. -// A museum-digital WebDAV directory can be identified by the availability of the -// directories IMPORT_IMG and IMPORT_XML. -// func verifyConnection(config MDWebDavUploaderConfig) bool { - -// } - -// Generates the contents of the file import_config.txt necessary -// to let museum-digital know about the required import configuration. -func generateImportConfigFile() { // string { - -} - - -// Uploads metadata files to the configured instance of -// museum-digital / musdb. -func uploadMetadataFiles() { - -} - -// Uploads media files to the configured instance of -// museum-digital / musdb. -func uploadMediaFiles() { - -} - +// Negotiates commands based on command line options. func main() { if slices.Contains(os.Args, "--help") { + } else if slices.Contains(os.Args, "--version") { + cli.ShowVersion(); } else if slices.Contains(os.Args, "--show-config") { cli.ShowCurrentConfig() } else if slices.Contains(os.Args, "--run-manual-setup") { diff --git a/makefile b/makefile new file mode 100644 index 0000000..d2a4c2d --- /dev/null +++ b/makefile @@ -0,0 +1,22 @@ +VERSION := $(shell go run main.go --version) + +hello: + echo WebDAV uploader for museum-digital + echo Version is $(VERSION) + +build: + go build -o bin/museum-digital-webdav-uploader main.go + +run: + go run main.go + +compile: + echo "Compiling for every OS and Platform" + GOOS=linux GOARCH=amd64 go build -o bin/museum-digital-webdav-uploader-$(VERSION)-linux-amd64 main.go + GOOS=windows GOARCH=amd64 go build -o bin/museum-digital-webdav-uploader-$(VERSION)-windows-amd64 main.go + GOOS=darwin GOARCH=amd64 go build -o bin/museum-digital-webdav-uploader-$(VERSION)-macos-amd64 main.go + GOOS=linux GOARCH=arm64 go build -o bin/museum-digital-webdav-uploader-$(VERSION)-linux-arm64 main.go + GOOS=windows GOARCH=arm64 go build -o bin/museum-digital-webdav-uploader-$(VERSION)-windows-arm64 main.go + GOOS=darwin GOARCH=arm64 go build -o bin/museum-digital-webdav-uploader-$(VERSION)-macos-arm64 main.go + +all: hello build diff --git a/src/cli/cli.go b/src/cli/cli.go index 667ba5e..e1ac8f2 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -9,6 +9,7 @@ import ( "gitea.armuli.eu/museum-digital/museum-digital-webdav-uploader/src/configloader" "gitea.armuli.eu/museum-digital/museum-digital-webdav-uploader/src/uploadsrcdir" "gitea.armuli.eu/museum-digital/museum-digital-webdav-uploader/src/webdavupload" + "gitea.armuli.eu/museum-digital/museum-digital-webdav-uploader/src/meta" ) // Interal wrapper around opening a new bufio.Reader and getting an input @@ -411,3 +412,8 @@ func HandleUpload() { fmt.Println("DONE") } + +// Prints current version. +func ShowVersion() { + fmt.Println(meta.GetVersion()) +} diff --git a/src/meta/meta.go b/src/meta/meta.go new file mode 100644 index 0000000..d0a719a --- /dev/null +++ b/src/meta/meta.go @@ -0,0 +1,6 @@ +package meta + +// Returns current version number. +func GetVersion() string { + return "0.1" +}