Compare commits
No commits in common. "master" and "v0.0.11" have entirely different histories.
|
@ -1,6 +1,6 @@
|
||||||
*.swp
|
*.swp
|
||||||
go.*
|
go.mod
|
||||||
*.pb.go
|
go.sum
|
||||||
|
|
||||||
files/
|
files/
|
||||||
|
|
||||||
|
|
20
Makefile
20
Makefile
|
@ -3,19 +3,19 @@
|
||||||
VERSION = $(shell git describe --tags)
|
VERSION = $(shell git describe --tags)
|
||||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||||
|
|
||||||
default: placement.pb.go install
|
default: 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
|
||||||
|
|
||||||
install: goimports
|
verbose:
|
||||||
GO111MODULE=off go install \
|
GO111MODULE=off go install -v -x \
|
||||||
-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
|
install: goimports
|
||||||
GO111MODULE=off go install -v -x \
|
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}"
|
||||||
|
|
||||||
# makes a .deb package
|
# makes a .deb package
|
||||||
|
@ -35,12 +35,4 @@ redomod:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
rm -f *.pb.go
|
rm -f virtigo*
|
||||||
rm -f startxplacement*
|
|
||||||
|
|
||||||
vet:
|
|
||||||
GO111MODULE=off go vet
|
|
||||||
@echo 'go vet' worked for this application
|
|
||||||
|
|
||||||
placement.pb.go: placement.proto
|
|
||||||
autogenpb --proto placement.proto
|
|
||||||
|
|
19
argv.go
19
argv.go
|
@ -3,11 +3,6 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this parses the command line arguements using alex flint's go-arg
|
this parses the command line arguements using alex flint's go-arg
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +14,6 @@ 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"`
|
||||||
|
@ -41,16 +35,3 @@ will attempt to launch your terminal windows on the right Workspaces
|
||||||
and with the right geometries. TODO: restore the bash working paths
|
and with the right geometries. TODO: restore the bash working paths
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a args) DoAutoComplete(argv []string) {
|
|
||||||
switch argv[0] {
|
|
||||||
case "dump":
|
|
||||||
fmt.Println("--terminals")
|
|
||||||
default:
|
|
||||||
if argv[0] == ARGNAME {
|
|
||||||
// list the subcommands here
|
|
||||||
fmt.Println("--restore save dump dumpx list")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the GPL 3.0
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
handles shell autocomplete
|
||||||
|
*/
|
||||||
|
|
||||||
|
// used for shell auto completion
|
||||||
|
// var ARGNAME string = "forge" // todo: get this from $0 ?
|
||||||
|
|
||||||
|
func deleteMatch() {
|
||||||
|
// f := forgedb.InitSimple()
|
||||||
|
fmt.Println("go.wit.com/lib/gui/repostatus todo: need to do this")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (args) doBashAuto() {
|
||||||
|
argv.doBashHelp()
|
||||||
|
switch argv.BashAuto[0] {
|
||||||
|
case "dump":
|
||||||
|
fmt.Println("--terminals")
|
||||||
|
default:
|
||||||
|
if argv.BashAuto[0] == ARGNAME {
|
||||||
|
// list the subcommands here
|
||||||
|
fmt.Println("--restore save dump dumpx")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// prints help to STDERR // TODO: move everything below this to go-args
|
||||||
|
func (args) doBashHelp() {
|
||||||
|
if len(argv.BashAuto) < 2 {
|
||||||
|
fmt.Fprintf(os.Stderr, "something went wrong with the GO args autocomplete in %s\n", ARGNAME)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if argv.BashAuto[1] != "''" {
|
||||||
|
// if this is not blank, then the user has typed something
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if argv.BashAuto[0] != ARGNAME {
|
||||||
|
// if this is not the name of the command, the user already started doing something
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if argv.BashAuto[0] == ARGNAME {
|
||||||
|
me.pp.WriteHelp(os.Stderr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Fprintln(os.Stderr, "")
|
||||||
|
fmt.Fprintln(os.Stderr, "something went wrong with the GO args package")
|
||||||
|
fmt.Fprintln(os.Stderr, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// complete -F forge --bash forge
|
||||||
|
func (args) doBash() {
|
||||||
|
if homeDir, err := os.UserHomeDir(); err == nil {
|
||||||
|
filename := filepath.Join(homeDir, ".local/share/bash-completion/completions", ARGNAME)
|
||||||
|
if !shell.Exists(filename) {
|
||||||
|
if f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
|
||||||
|
f.Write([]byte(makeBashCompletionText(ARGNAME)))
|
||||||
|
f.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println(makeBashCompletionText(ARGNAME))
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeBashCompletionText(argname string) string {
|
||||||
|
var out string
|
||||||
|
|
||||||
|
out += fmt.Sprintf("# add this in your bashrc:\n")
|
||||||
|
out += fmt.Sprintf("\n")
|
||||||
|
out += fmt.Sprintf("# todo: add this to go-arg as a 'hidden' go-arg option --bash\n")
|
||||||
|
out += fmt.Sprintf("#\n")
|
||||||
|
out += fmt.Sprintf("# Put the below in the file: ~/.local/share/bash-completion/completions/%s\n", argname)
|
||||||
|
out += fmt.Sprintf("#\n")
|
||||||
|
out += fmt.Sprintf("# todo: make this output work/parse with:\n")
|
||||||
|
out += fmt.Sprintf("# complete -C " + argname + " --bash go\n")
|
||||||
|
out += fmt.Sprintf("\n")
|
||||||
|
out += fmt.Sprintf("_" + argname + "_complete()\n")
|
||||||
|
out += fmt.Sprintf("{\n")
|
||||||
|
out += fmt.Sprintf(" # sets local to this func vars\n")
|
||||||
|
out += fmt.Sprintf(" local cur prev all\n")
|
||||||
|
out += fmt.Sprintf(" cur=${COMP_WORDS[COMP_CWORD]}\n")
|
||||||
|
out += fmt.Sprintf(" prev=${COMP_WORDS[COMP_CWORD-1]}\n")
|
||||||
|
out += fmt.Sprintf(" all=${COMP_WORDS[@]}\n")
|
||||||
|
out += fmt.Sprintf("\n")
|
||||||
|
out += fmt.Sprintf(" # this is where we generate the go-arg output\n")
|
||||||
|
out += fmt.Sprintf(" GOARGS=$(" + argname + " --auto-complete $prev \\'$cur\\' $all)\n")
|
||||||
|
out += fmt.Sprintf("\n")
|
||||||
|
out += fmt.Sprintf(" # this compares the command line input from the user\n")
|
||||||
|
out += fmt.Sprintf(" # to whatever strings we output\n")
|
||||||
|
out += fmt.Sprintf(" COMPREPLY=( $(compgen -W \"$GOARGS\" -- $cur) ) # THIS WORKS\n")
|
||||||
|
out += fmt.Sprintf(" return 0\n")
|
||||||
|
out += fmt.Sprintf("}\n")
|
||||||
|
out += fmt.Sprintf("complete -F _%s_complete %s\n", argname, argname)
|
||||||
|
out += fmt.Sprintf("\n")
|
||||||
|
out += fmt.Sprintf("# copy and paste the above into your bash shell should work\n")
|
||||||
|
return out
|
||||||
|
}
|
20
main.go
20
main.go
|
@ -7,9 +7,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/lib/gui/prep"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,19 +28,22 @@ var configFile string = "/home/jcarr/.config/startxplacement.out"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(mainType)
|
me = new(mainType)
|
||||||
prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: this line should be: prep.Bash(argv)
|
gui.InitArg()
|
||||||
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
|
||||||
me.pp = arg.MustParse(&argv)
|
me.pp = arg.MustParse(&argv)
|
||||||
|
|
||||||
|
if argv.Bash {
|
||||||
|
argv.doBash()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
if len(argv.BashAuto) != 0 {
|
||||||
|
argv.doBashAuto()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if argv.DumpX != nil {
|
if argv.DumpX != nil {
|
||||||
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()
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
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")
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/lib/gui/prep"
|
"go.wit.com/gui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *mainType
|
var me *mainType
|
||||||
|
@ -13,5 +13,5 @@ var me *mainType
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type mainType struct {
|
type mainType struct {
|
||||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
||||||
myGui *prep.GuiPrep // the gui toolkit handle
|
myGui *gui.Node // the gui toolkit handle
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue