Skip to content

Commit

Permalink
list,unshare: dissalow -r without path
Browse files Browse the repository at this point in the history
  • Loading branch information
gnojus committed Jan 9, 2023
1 parent 9219cff commit 01e5d7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type pathConfig struct {
// optPathConfig is like pathConfig, but the Path is optional.
// If Path is empty, it looks for a single account to match.
type optPathConfig struct {
Path string `arg:"" optional:"" help:"file on local filesystem. Empty matches all files,xor=opath"`
Path string `arg:"" optional:"" help:"file on local filesystem. Empty matches all files"`
account
remoteFile string
accounts []account
Expand Down
10 changes: 9 additions & 1 deletion list.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"
"net/url"
"os"
Expand All @@ -12,13 +13,20 @@ import (
type list struct {
optPathConfig

Recursive bool `kong:"short=r,help='recursively descend into folders',xor=opath"`
Recursive bool `kong:"short=r,help='recursively descend into folders'"`
}

func isSubfile(dir, f string) bool {
return dir == "/" || dir == f || strings.HasPrefix(f, dir+"/")
}

func (l *list) AfterApply() error {
if l.Path == "" && l.Recursive {
return errors.New("omitted path matches all shares, --recursive (-r) is unnecessary")
}
return nil
}

func (l *list) Run() error {
accounts := l.accounts
if l.remoteFile != "" {
Expand Down

0 comments on commit 01e5d7d

Please sign in to comment.