summaryrefslogtreecommitdiff
path: root/forgeConfig
diff options
context:
space:
mode:
Diffstat (limited to 'forgeConfig')
-rw-r--r--forgeConfig/Makefile9
-rw-r--r--forgeConfig/argv.go5
-rw-r--r--forgeConfig/main.go18
3 files changed, 31 insertions, 1 deletions
diff --git a/forgeConfig/Makefile b/forgeConfig/Makefile
index 942ee78..ddf8079 100644
--- a/forgeConfig/Makefile
+++ b/forgeConfig/Makefile
@@ -7,6 +7,15 @@ build:
./forgeConfig
FORGE_HOME=/tmp/forge ./forgeConfig
+test:
+ ./forgeConfig --list
+ ./forgeConfig --add --gopath 'go.wit.com/apps/foo'
+ ./forgeConfig --add --gopath 'go.wit.com/apps/foowrite' --writable
+ ./forgeConfig --add --gopath 'gitea.wit.com' --directory
+ ./forgeConfig --add --gopath 'git.wit.org' --directory
+ ./forgeConfig --delete --gopath 'go.wit.com/apps/helloworld'
+ ./forgeConfig --list
+
list:
./forgeConfig --list
diff --git a/forgeConfig/argv.go b/forgeConfig/argv.go
index 9081e9e..6493284 100644
--- a/forgeConfig/argv.go
+++ b/forgeConfig/argv.go
@@ -12,8 +12,11 @@ type args struct {
ConfigDir string `arg:"env:FORGE_HOME" help:"defaults to ~/.config/forge/"`
List bool `arg:"--list" default:"false" help:"list repos in your config"`
Add bool `arg:"--add" default:"false" help:"add a new repo"`
+ Delete bool `arg:"--delete" default:"false" help:"delete a repo"`
Update bool `arg:"--update" default:"false" help:"update a repo"`
- Name string `arg:"--name" help:"name of the repo"`
+ Directory bool `arg:"--directory" default:"false" help:"repo is a directory to match against"`
+ ReadOnly bool `arg:"--readonly" default:"false" help:"repo is readonly"`
+ Writable bool `arg:"--writable" default:"false" help:"repo is writable"`
GoPath string `arg:"--gopath" help:"gopath of the repo"`
}
diff --git a/forgeConfig/main.go b/forgeConfig/main.go
index 434f222..237698c 100644
--- a/forgeConfig/main.go
+++ b/forgeConfig/main.go
@@ -26,6 +26,19 @@ func main() {
}
os.Exit(0)
}
+
+ // try to delete, then save config and exit
+ if argv.Delete {
+ if oldr := repos.DeleteByPath(argv.GoPath); oldr == nil {
+ log.Info("deleted", argv.GoPath, "did not exist. did nothing")
+ os.Exit(0)
+ }
+ log.Info("deleted", argv.GoPath, "ok")
+ repos.ConfigSave()
+ os.Exit(0)
+ }
+
+ // try to update, then save config and exit
if argv.Update {
/*
if repos.UpdateGoPath(argv.Name, argv.GoPath) {
@@ -35,10 +48,15 @@ func main() {
*/
os.Exit(0)
}
+
+ // try to add, then save config and exit
if argv.Add {
log.Info("going to add a new repo", argv.GoPath)
new1 := new(forgepb.Repo)
new1.GoPath = argv.GoPath
+ new1.Writable = argv.Writable
+ new1.ReadOnly = argv.ReadOnly
+ new1.Directory = argv.Directory
if repos.Append(new1) {
log.Info("added", new1.GoPath, "ok")
} else {