load/save config files
This commit is contained in:
parent
c3f5588365
commit
94bd4728ba
|
@ -1,6 +1,6 @@
|
||||||
*.swp
|
*.swp
|
||||||
go.mod
|
go.*
|
||||||
go.sum
|
*.pb.go
|
||||||
|
|
||||||
files/
|
files/
|
||||||
|
|
||||||
|
|
20
Makefile
20
Makefile
|
@ -3,21 +3,21 @@
|
||||||
VERSION = $(shell git describe --tags)
|
VERSION = $(shell git describe --tags)
|
||||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
|
|
||||||
default: install
|
default: placement.pb.go install
|
||||||
|
|
||||||
build:
|
build:
|
||||||
GO111MODULE=off go build \
|
GO111MODULE=off go build \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
./startxplacement
|
./startxplacement
|
||||||
|
|
||||||
verbose:
|
|
||||||
GO111MODULE=off go install -v -x \
|
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
|
||||||
|
|
||||||
install: goimports
|
install: goimports
|
||||||
GO111MODULE=off go install \
|
GO111MODULE=off go install \
|
||||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
|
install-verbose: goimports vet
|
||||||
|
GO111MODULE=off go install -v -x \
|
||||||
|
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||||
|
|
||||||
# makes a .deb package
|
# makes a .deb package
|
||||||
debian:
|
debian:
|
||||||
rm -f ~/incoming/virtigo*deb
|
rm -f ~/incoming/virtigo*deb
|
||||||
|
@ -35,4 +35,12 @@ redomod:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
rm -f virtigo*
|
rm -f *.pb.go
|
||||||
|
rm -f startxplacement*
|
||||||
|
|
||||||
|
vet:
|
||||||
|
GO111MODULE=off go vet
|
||||||
|
@echo 'go vet' worked for this application
|
||||||
|
|
||||||
|
placement.pb.go: placement.proto
|
||||||
|
autogenpb --proto placement.proto
|
||||||
|
|
3
argv.go
3
argv.go
|
@ -19,6 +19,7 @@ type args struct {
|
||||||
Save *EmptyCmd `arg:"subcommand:save" help:"save current window geometries to the your config file"`
|
Save *EmptyCmd `arg:"subcommand:save" help:"save current window geometries to the your config file"`
|
||||||
DumpX *EmptyCmd `arg:"subcommand:dumpx" help:"show your current window geometries"`
|
DumpX *EmptyCmd `arg:"subcommand:dumpx" help:"show your current window geometries"`
|
||||||
Dump *EmptyCmd `arg:"subcommand:dump" help:"show your current window geometries"`
|
Dump *EmptyCmd `arg:"subcommand:dump" help:"show your current window geometries"`
|
||||||
|
List *EmptyCmd `arg:"subcommand:list" help:"list entries in your config file"`
|
||||||
Force bool `arg:"--force" help:"try to strong arm things"`
|
Force bool `arg:"--force" help:"try to strong arm things"`
|
||||||
Verbose bool `arg:"--verbose" help:"show more output"`
|
Verbose bool `arg:"--verbose" help:"show more output"`
|
||||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||||
|
@ -48,7 +49,7 @@ func (a args) DoAutoComplete(argv []string) {
|
||||||
default:
|
default:
|
||||||
if argv[0] == ARGNAME {
|
if argv[0] == ARGNAME {
|
||||||
// list the subcommands here
|
// list the subcommands here
|
||||||
fmt.Println("--restore save dump dumpx")
|
fmt.Println("--restore save dump dumpx list")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
5
main.go
5
main.go
|
@ -35,6 +35,11 @@ func main() {
|
||||||
doDumpX()
|
doDumpX()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if argv.List != nil {
|
||||||
|
log.Info("list the config")
|
||||||
|
okExit("")
|
||||||
|
}
|
||||||
|
|
||||||
if argv.Dump != nil {
|
if argv.Dump != nil {
|
||||||
// 2. Get the current state of all terminal windows.
|
// 2. Get the current state of all terminal windows.
|
||||||
currentStates, err := getCurrentState()
|
currentStates, err := getCurrentState()
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// functions to import and export the protobuf
|
||||||
|
// data to and from config files
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/lib/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (pb *Placements) ConfigSave() error {
|
||||||
|
return config.ConfigSave(pb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pb *Placements) ConfigLoad() error {
|
||||||
|
return config.ConfigLoad(pb, ARGNAME, "placements")
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package main;
|
||||||
|
|
||||||
|
message Placement {
|
||||||
|
message Size {
|
||||||
|
int64 w = 1;
|
||||||
|
int64 h = 2;
|
||||||
|
}
|
||||||
|
message Offset {
|
||||||
|
int64 x = 1;
|
||||||
|
int64 y = 2;
|
||||||
|
}
|
||||||
|
message Geom {
|
||||||
|
Size size = 1;
|
||||||
|
Offset offset = 2;
|
||||||
|
}
|
||||||
|
// used for grid layouts
|
||||||
|
string name = 1; // `autogenpb:sort` `autogenpb:unique`
|
||||||
|
Geom geom = 2;
|
||||||
|
int32 workspace = 3; // what workspace to show the app on
|
||||||
|
string wd = 4; // working dir. Tries to set xterm path at start to this
|
||||||
|
repeated string argv = 5; // argv. argv[0] should be the executable name
|
||||||
|
string namespace = 6; // namespace of the executable (go.wit.com/apps/forge)
|
||||||
|
}
|
||||||
|
message Placements { // `autogenpb:marshal` `autogenpb:mutex`
|
||||||
|
string uuid = 1; // `autogenpb:uuid:31769bcb-5865-4926-b7d6-501083312eea`
|
||||||
|
string version = 2; // `autogenpb:version:v0.0.1`
|
||||||
|
repeated Placement Placement = 3;
|
||||||
|
string filename = 4; // used by the config save function
|
||||||
|
}
|
Loading…
Reference in New Issue