Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No glob #25530

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

No glob #25530

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions go/client/cmd_simplefs_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CmdSimpleFSCopy struct {
recurse bool
interactive bool
force bool
noglob bool
opCanceler *OpCanceler
}

Expand Down Expand Up @@ -53,6 +54,10 @@ func NewCmdSimpleFSCopy(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.
Name: "f, force",
Usage: "force overwrite",
},
cli.BoolFlag{
Name: "G, no-glob",
Usage: "Do not perform glob expansion",
},
cli.IntFlag{
Name: "rev",
Usage: "a revision number for the KBFS folder of the source paths",
Expand Down Expand Up @@ -80,9 +85,13 @@ func (c *CmdSimpleFSCopy) Run() error {

c.G().Log.Debug("SimpleFSCopy (recursive: %v) to: %s", c.recurse, c.dest)

destPaths, err := doSimpleFSGlob(ctx, c.G(), cli, c.src)
if err != nil {
return err
destPaths := c.src

if ! c.noglob {
destPaths, err = doSimpleFSGlob(ctx, c.G(), cli, c.src)
if err != nil {
return err
}
}

// Eat the error because it's ok here if the dest doesn't exist
Expand Down Expand Up @@ -150,6 +159,7 @@ func (c *CmdSimpleFSCopy) ParseArgv(ctx *cli.Context) error {
c.recurse = ctx.Bool("recursive")
c.interactive = ctx.Bool("interactive")
c.force = ctx.Bool("force")
c.noglob = ctx.Bool("no-glob")

if c.force && c.interactive {
return errors.New("force and interactive are incompatible")
Expand Down
16 changes: 13 additions & 3 deletions go/client/cmd_simplefs_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type CmdSimpleFSList struct {
libkb.Contextified
paths []keybase1.Path
recurse bool
noglob bool
winStyle bool
options ListOptions
}
Expand All @@ -55,6 +56,10 @@ func NewCmdSimpleFSList(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.
Name: "rec, recursive",
Usage: "recurse into subdirectories",
},
cli.BoolFlag{
Name: "G, no-glob",
Usage: "Do not perform glob expansion",
},
/* TODO: currently this option does nothing.
cli.BoolFlag{
Name: "dirs-first",
Expand Down Expand Up @@ -164,9 +169,13 @@ func (c *CmdSimpleFSList) Run() error {

ctx := context.TODO()

paths, err := doSimpleFSGlob(ctx, c.G(), cli, c.paths)
if err != nil {
return err
paths := c.paths

if ! c.noglob {
paths, err = doSimpleFSGlob(ctx, c.G(), cli, c.paths)
if err != nil {
return err
}
}

// If the argument was globbed, we really just want a stat of each item
Expand Down Expand Up @@ -283,6 +292,7 @@ func (c *CmdSimpleFSList) ParseArgv(ctx *cli.Context) error {

c.recurse = ctx.Bool("rec") || ctx.Bool("recursive")
c.winStyle = ctx.Bool("windows")
c.noglob = ctx.Bool("no-glob")
c.options.all = ctx.Bool("all")
c.options.long = ctx.Bool("long")
c.options.one = ctx.Bool("one")
Expand Down
15 changes: 12 additions & 3 deletions go/client/cmd_simplefs_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type CmdSimpleFSMove struct {
dest keybase1.Path
interactive bool
force bool
noglob bool
opCanceler *OpCanceler
}

Expand Down Expand Up @@ -48,6 +49,10 @@ func NewCmdSimpleFSMove(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.
Name: "f, force",
Usage: "force overwrite",
},
cli.BoolFlag{
Name: "no-glob",
Usage: "Do not perform glob expansion",
},
},
}
}
Expand All @@ -60,10 +65,13 @@ func (c *CmdSimpleFSMove) Run() error {
}

ctx := context.TODO()
destPaths := c.src

destPaths, err := doSimpleFSGlob(ctx, c.G(), cli, c.src)
if err != nil {
return err
if ! c.noglob {
destPaths, err = doSimpleFSGlob(ctx, c.G(), cli, c.src)
if err != nil {
return err
}
}

// Eat the error because it's ok here if the dest doesn't exist
Expand Down Expand Up @@ -121,6 +129,7 @@ func (c *CmdSimpleFSMove) ParseArgv(ctx *cli.Context) error {
var err error
c.interactive = ctx.Bool("interactive")
c.force = ctx.Bool("force")
c.noglob = ctx.Bool("G, no-glob")

if c.force && c.interactive {
return errors.New("force and interactive are incompatible")
Expand Down
16 changes: 13 additions & 3 deletions go/client/cmd_simplefs_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type CmdSimpleFSRemove struct {
libkb.Contextified
paths []keybase1.Path
recurse bool
noglob bool
}

// NewCmdSimpleFSRemove creates a new cli.Command.
Expand All @@ -36,6 +37,10 @@ func NewCmdSimpleFSRemove(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cl
Name: "r, recursive",
Usage: "Recursively delete everything in a directory",
},
cli.BoolFlag{
Name: "G, no-glob",
Usage: "Do not perform glob expansion",
},
},
}
}
Expand All @@ -49,9 +54,13 @@ func (c *CmdSimpleFSRemove) Run() error {

ctx := context.TODO()

paths, err := doSimpleFSGlob(ctx, c.G(), cli, c.paths)
if err != nil {
return err
paths := c.paths

if ! c.noglob {
paths, err = doSimpleFSGlob(ctx, c.G(), cli, c.paths)
if err != nil {
return err
}
}

for _, path := range paths {
Expand Down Expand Up @@ -80,6 +89,7 @@ func (c *CmdSimpleFSRemove) Run() error {
// ParseArgv gets the required path argument for this command.
func (c *CmdSimpleFSRemove) ParseArgv(ctx *cli.Context) error {
c.recurse = ctx.Bool("recursive")
c.noglob = ctx.Bool("no-glob")

nargs := len(ctx.Args())
var err error
Expand Down