- commit
- e7ce4a1
- parent
- a5c22ce
- author
- Eric Bower
- date
- 2024-02-28 04:07:06 +0000 UTC
fix write flag
1 files changed,
+8,
-8
+8,
-8
1@@ -44,11 +44,11 @@ func (i *arrayFlags) Set(value string) error {
2 return nil
3 }
4
5-func flagSet(cmdName string, sesh ssh.Session) (*flag.FlagSet, bool) {
6+func flagSet(cmdName string, sesh ssh.Session) (*flag.FlagSet, *bool) {
7 cmd := flag.NewFlagSet(cmdName, flag.ContinueOnError)
8 cmd.SetOutput(sesh)
9 write := cmd.Bool("write", false, "apply changes")
10- return cmd, *write
11+ return cmd, write
12 }
13
14 func flagCheck(cmd *flag.FlagSet, posArg string, cmdArgs []string) bool {
15@@ -123,11 +123,11 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
16
17 if cmd == "link" {
18 linkCmd, write := flagSet("link", sesh)
19- opts.Write = write
20 linkTo := linkCmd.String("to", "", "symbolic link to this project")
21 if !flagCheck(linkCmd, projectName, cmdArgs) {
22 return
23 }
24+ opts.Write = *write
25
26 if *linkTo == "" {
27 err := fmt.Errorf(
28@@ -145,10 +145,10 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
29 return
30 } else if cmd == "unlink" {
31 unlinkCmd, write := flagSet("unlink", sesh)
32- opts.Write = write
33 if !flagCheck(unlinkCmd, projectName, cmdArgs) {
34 return
35 }
36+ opts.Write = *write
37
38 err := opts.unlink(projectName)
39 opts.notice()
40@@ -160,11 +160,11 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
41 return
42 } else if cmd == "retain" {
43 retainCmd, write := flagSet("retain", sesh)
44- opts.Write = write
45 retainNum := retainCmd.Int("n", 3, "latest number of projects to keep")
46 if !flagCheck(retainCmd, projectName, cmdArgs) {
47 return
48 }
49+ opts.Write = *write
50
51 err := opts.prune(projectName, *retainNum)
52 opts.notice()
53@@ -172,10 +172,10 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
54 return
55 } else if cmd == "prune" {
56 pruneCmd, write := flagSet("prune", sesh)
57- opts.Write = write
58 if !flagCheck(pruneCmd, projectName, cmdArgs) {
59 return
60 }
61+ opts.Write = *write
62
63 err := opts.prune(projectName, 0)
64 opts.notice()
65@@ -183,10 +183,10 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
66 return
67 } else if cmd == "rm" {
68 rmCmd, write := flagSet("rm", sesh)
69- opts.Write = write
70 if !flagCheck(rmCmd, projectName, cmdArgs) {
71 return
72 }
73+ opts.Write = *write
74
75 err := opts.rm(projectName)
76 opts.notice()
77@@ -194,7 +194,6 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
78 return
79 } else if cmd == "acl" {
80 aclCmd, write := flagSet("acl", sesh)
81- opts.Write = write
82 aclType := aclCmd.String("type", "", "access type: public, pico, pubkeys")
83 var acls arrayFlags
84 aclCmd.Var(
85@@ -205,6 +204,7 @@ func WishMiddleware(handler *uploadassets.UploadAssetHandler) wish.Middleware {
86 if !flagCheck(aclCmd, projectName, cmdArgs) {
87 return
88 }
89+ opts.Write = *write
90
91 if !slices.Contains([]string{"public", "pubkeys", "pico"}, *aclType) {
92 err := fmt.Errorf(