local: implement backend command "noop" for testing purposes
This commit is contained in:
parent
1aa1a2c174
commit
e2916f3a55
2 changed files with 76 additions and 0 deletions
|
@ -41,6 +41,7 @@ func init() {
|
||||||
Name: "local",
|
Name: "local",
|
||||||
Description: "Local Disk",
|
Description: "Local Disk",
|
||||||
NewFs: NewFs,
|
NewFs: NewFs,
|
||||||
|
CommandHelp: commandHelp,
|
||||||
Options: []fs.Option{{
|
Options: []fs.Option{{
|
||||||
Name: "nounc",
|
Name: "nounc",
|
||||||
Help: "Disable UNC (long path names) conversion on Windows",
|
Help: "Disable UNC (long path names) conversion on Windows",
|
||||||
|
@ -697,6 +698,50 @@ func (f *Fs) Hashes() hash.Set {
|
||||||
return hash.Supported()
|
return hash.Supported()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var commandHelp = []fs.CommandHelp{
|
||||||
|
{
|
||||||
|
Name: "noop",
|
||||||
|
Short: "A null operation for testing backend commands",
|
||||||
|
Long: `This is a test command which has some options
|
||||||
|
you can try to change the output.`,
|
||||||
|
Opts: map[string]string{
|
||||||
|
"echo": "echo the input arguments",
|
||||||
|
"error": "return an error based on option value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command the backend to run a named command
|
||||||
|
//
|
||||||
|
// The command run is name
|
||||||
|
// args may be used to read arguments from
|
||||||
|
// opts may be used to read optional arguments from
|
||||||
|
//
|
||||||
|
// The result should be capable of being JSON encoded
|
||||||
|
// If it is a string or a []string it will be shown to the user
|
||||||
|
// otherwise it will be JSON encoded and shown to the user like that
|
||||||
|
func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[string]string) (interface{}, error) {
|
||||||
|
switch name {
|
||||||
|
case "noop":
|
||||||
|
if txt, ok := opt["error"]; ok {
|
||||||
|
if txt == "" {
|
||||||
|
txt = "unspecified error"
|
||||||
|
}
|
||||||
|
return nil, errors.New(txt)
|
||||||
|
}
|
||||||
|
if _, ok := opt["echo"]; ok {
|
||||||
|
out := map[string]interface{}{}
|
||||||
|
out["name"] = name
|
||||||
|
out["arg"] = arg
|
||||||
|
out["opt"] = opt
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
default:
|
||||||
|
return nil, fs.ErrorCommandNotFound
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
// Fs returns the parent Fs
|
// Fs returns the parent Fs
|
||||||
|
@ -1164,6 +1209,7 @@ var (
|
||||||
_ fs.PutStreamer = &Fs{}
|
_ fs.PutStreamer = &Fs{}
|
||||||
_ fs.Mover = &Fs{}
|
_ fs.Mover = &Fs{}
|
||||||
_ fs.DirMover = &Fs{}
|
_ fs.DirMover = &Fs{}
|
||||||
|
_ fs.Commander = &Fs{}
|
||||||
_ fs.OpenWriterAter = &Fs{}
|
_ fs.OpenWriterAter = &Fs{}
|
||||||
_ fs.Object = &Object{}
|
_ fs.Object = &Object{}
|
||||||
)
|
)
|
||||||
|
|
|
@ -424,4 +424,34 @@ See: the [encoding section in the overview](/overview/#encoding) for more info.
|
||||||
- Type: MultiEncoder
|
- Type: MultiEncoder
|
||||||
- Default: Slash,Dot
|
- Default: Slash,Dot
|
||||||
|
|
||||||
|
### Backend commands
|
||||||
|
|
||||||
|
Here are the commands specific to the local backend.
|
||||||
|
|
||||||
|
Run them with with
|
||||||
|
|
||||||
|
rclone backend COMMAND remote:
|
||||||
|
|
||||||
|
The help below will explain what arguments each command takes.
|
||||||
|
|
||||||
|
See [the "rclone backend" command](/commands/rclone_backend/) for more
|
||||||
|
info on how to pass options and arguments.
|
||||||
|
|
||||||
|
These can be run on a running backend using the rc command
|
||||||
|
[backend/command](/rc/#backend/command).
|
||||||
|
|
||||||
|
#### noop
|
||||||
|
|
||||||
|
A null operation for testing backend commands
|
||||||
|
|
||||||
|
rclone backend noop remote: [options] [<arguments>+]
|
||||||
|
|
||||||
|
This is a test command which has some options
|
||||||
|
you can try to change the output.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
- "echo": echo the input arguments
|
||||||
|
- "error": return an error based on option value
|
||||||
|
|
||||||
<!--- autogenerated options stop -->
|
<!--- autogenerated options stop -->
|
||||||
|
|
Loading…
Reference in a new issue