The very basic client app, not adapted for mobiles.
This commit is contained in:
88
client/cmd/client/Taskfile.yml
Normal file
88
client/cmd/client/Taskfile.yml
Normal file
@@ -0,0 +1,88 @@
|
||||
---
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
ClientBinary: name.pztrn.bunker.client{{exeExt}}
|
||||
MetadataParams: --metadata "Branch={{ .BRANCH }}" --metadata "Build={{ .BUILD }}" --metadata "BuildDate={{ .BUILD_DATE }}" --metadata "Commit={{ .COMMIT }}" --metadata "Version={{ .VERSION }}"
|
||||
|
||||
env:
|
||||
CGO_ENABLED: 1
|
||||
|
||||
tasks:
|
||||
build:
|
||||
desc: "Build client."
|
||||
dir: ./client/cmd/client
|
||||
internal: true
|
||||
cmds:
|
||||
- task: ::ensure-builddir
|
||||
- task: cleanup
|
||||
- fyne build --release -o ../../../.build/{{ .ClientBinary }} --pprof --pprof-port 6060 {{ .MetadataParams }}
|
||||
|
||||
build-debug:
|
||||
desc: "Build client in debug mode."
|
||||
internal: true
|
||||
dir: ./client/cmd/client
|
||||
cmds:
|
||||
- task: ::ensure-builddir
|
||||
- task: cleanup
|
||||
- fyne build -o ../../../.build/{{ .ClientBinary }} --tags debug {{ .MetadataParams }}
|
||||
|
||||
# build-production:
|
||||
# desc: "Build production package for current OS."
|
||||
# dir: ./client/cmd/client
|
||||
# cmds:
|
||||
# - task: ::ensure-builddir
|
||||
# - task: cleanup
|
||||
# - fyne package --release --app-id name.pztrn.bunker.client -executable name.pztrn.bunker.client -icon ../../Icon.png --release --name "pztrn's Bunker" --app-version "{{ .CLIENT_VERSION }}" --app-build "{{ .BUILD }}" {{ .MetadataParams }}
|
||||
|
||||
# build-web:
|
||||
# desc: "Build web version."
|
||||
# dir: ./client/cmd/client
|
||||
# cmds:
|
||||
# - fyne package -os web --app-id name.pztrn.bunker.client -icon ../../Icon.png --release --name "pztrn's Bunker" --app-version "{{ .CLIENT_VERSION }}" --app-build "{{ .BUILD }}" {{ .MetadataParams }}
|
||||
|
||||
build-darwin-amd64:
|
||||
desc: "Build darwin/arm64 using fyne-cross"
|
||||
cmds:
|
||||
- task: ::ensure-builddir
|
||||
- task: cleanup
|
||||
- fyne-cross darwin -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -arch=amd64 -category=6007 -pull client/cmd/client
|
||||
|
||||
build-darwin-arm64:
|
||||
desc: "Build darwin/arm64 using fyne-cross"
|
||||
cmds:
|
||||
- task: ::ensure-builddir
|
||||
- task: cleanup
|
||||
- fyne-cross darwin -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -arch=arm64 -category=6007 -pull client/cmd/client
|
||||
|
||||
build-linux-amd64:
|
||||
desc: "Build linux/amd64 using fyne-cross"
|
||||
cmds:
|
||||
- task: ::ensure-builddir
|
||||
- task: cleanup
|
||||
- fyne-cross linux -app-id=name.pztrn.bunker.client -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -icon=client/Icon.png -arch=amd64 -name="pztrn's Bunker" -pull client/cmd/client
|
||||
|
||||
build-windows-amd64:
|
||||
desc: "Build windows/amd64 using fyne-cross"
|
||||
cmds:
|
||||
- task: ::ensure-builddir
|
||||
- task: cleanup
|
||||
- fyne-cross windows -app-id=name.pztrn.bunker.client -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -icon=client/Icon.png -arch=amd64 -name="pztrn's Bunker" -pull client/cmd/client
|
||||
|
||||
cleanup:
|
||||
desc: "Cleanup build environment."
|
||||
cmds:
|
||||
- rm .build/{{ .ClientBinary }}
|
||||
ignore_error: true
|
||||
|
||||
run:
|
||||
desc: "Launch client."
|
||||
cmds:
|
||||
- task: build
|
||||
- .build/{{ .ClientBinary }}
|
||||
|
||||
run-debug:
|
||||
desc: "Launch client in debug mode."
|
||||
cmds:
|
||||
- task: build-debug
|
||||
- .build/{{ .ClientBinary }}
|
69
client/cmd/client/main.go
Normal file
69
client/cmd/client/main.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"bunker/client/internal/application"
|
||||
"bunker/client/internal/services/core/database"
|
||||
"bunker/client/internal/services/core/mainwindow"
|
||||
"bunker/client/internal/services/core/options"
|
||||
"bunker/client/internal/services/core/translations"
|
||||
"bunker/commons"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func main() {
|
||||
slog.Info("Starting Bunker client...")
|
||||
|
||||
_ = slog.SetLogLoggerLevel(slog.LevelDebug)
|
||||
|
||||
app := application.New()
|
||||
|
||||
checkError(translations.Initialize(app))
|
||||
checkError(database.Initialize(app))
|
||||
checkError(options.Initialize(app))
|
||||
checkError(mainwindow.Initialize(app))
|
||||
|
||||
checkError(app.Start())
|
||||
}
|
||||
|
||||
func checkError(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fyneApp := app.NewWithID(commons.ClientAppID)
|
||||
|
||||
wnd := fyneApp.NewWindow("pztrn's Bunker - Error occurred!")
|
||||
//nolint:mnd
|
||||
wnd.Resize(fyne.NewSize(550, 300))
|
||||
|
||||
lbl := widget.NewLabel("Error appeared while starting pztrn's Bunker:")
|
||||
lbl.Wrapping = fyne.TextWrapWord
|
||||
|
||||
errLabel := widget.NewLabel(err.Error())
|
||||
errLabel.Wrapping = fyne.TextWrapWord
|
||||
|
||||
lbl2 := widget.NewLabel("Please, report this to developer!")
|
||||
lbl2.Wrapping = fyne.TextWrapWord
|
||||
|
||||
copyToClipboardButton := widget.NewButton("Copy to clipboard", func() {
|
||||
fyneApp.Clipboard().SetContent(err.Error())
|
||||
})
|
||||
|
||||
wnd.SetContent(container.NewVBox(
|
||||
lbl,
|
||||
errLabel,
|
||||
lbl2,
|
||||
copyToClipboardButton,
|
||||
))
|
||||
|
||||
wnd.ShowAndRun()
|
||||
|
||||
os.Exit(1)
|
||||
}
|
Reference in New Issue
Block a user