diff --git a/cmd/genautocomplete/genautocomplete.go b/cmd/genautocomplete/genautocomplete.go index 72c227a88..d346c74fc 100644 --- a/cmd/genautocomplete/genautocomplete.go +++ b/cmd/genautocomplete/genautocomplete.go @@ -1,44 +1,19 @@ package genautocomplete import ( - "log" - "github.com/ncw/rclone/cmd" "github.com/spf13/cobra" ) func init() { - cmd.Root.AddCommand(commandDefintion) + cmd.Root.AddCommand(completionDefinition) } -var commandDefintion = &cobra.Command{ - Use: "genautocomplete [output_file]", - Short: `Output bash completion script for rclone.`, +var completionDefinition = &cobra.Command{ + Use: "genautocomplete [shell]", + Short: `Output completion script for a given shell.`, Long: ` -Generates a bash shell autocompletion script for rclone. - -This writes to /etc/bash_completion.d/rclone by default so will -probably need to be run with sudo or as root, eg - - sudo rclone genautocomplete - -Logout and login again to use the autocompletion scripts, or source -them directly - - . /etc/bash_completion - -If you supply a command line argument the script will be written -there. +Generates a shell completion script for rclone. +Run with --help to list the supported shells. `, - Run: func(command *cobra.Command, args []string) { - cmd.CheckArgs(0, 1, command, args) - out := "/etc/bash_completion.d/rclone" - if len(args) > 0 { - out = args[0] - } - err := cmd.Root.GenBashCompletionFile(out) - if err != nil { - log.Fatal(err) - } - }, } diff --git a/cmd/genautocomplete/genautocomplete_bash.go b/cmd/genautocomplete/genautocomplete_bash.go new file mode 100644 index 000000000..11de54e77 --- /dev/null +++ b/cmd/genautocomplete/genautocomplete_bash.go @@ -0,0 +1,44 @@ +package genautocomplete + +import ( + "log" + + "github.com/ncw/rclone/cmd" + "github.com/spf13/cobra" +) + +func init() { + completionDefinition.AddCommand(bashCommandDefinition) +} + +var bashCommandDefinition = &cobra.Command{ + Use: "bash [output_file]", + Short: `Output bash completion script for rclone.`, + Long: ` +Generates a bash shell autocompletion script for rclone. + +This writes to /etc/bash_completion.d/rclone by default so will +probably need to be run with sudo or as root, eg + + sudo rclone genautocomplete bash + +Logout and login again to use the autocompletion scripts, or source +them directly + + . /etc/bash_completion + +If you supply a command line argument the script will be written +there. +`, + Run: func(command *cobra.Command, args []string) { + cmd.CheckArgs(0, 1, command, args) + out := "/etc/bash_completion.d/rclone" + if len(args) > 0 { + out = args[0] + } + err := cmd.Root.GenBashCompletionFile(out) + if err != nil { + log.Fatal(err) + } + }, +} diff --git a/cmd/genautocomplete/genautocomplete_test.go b/cmd/genautocomplete/genautocomplete_test.go new file mode 100644 index 000000000..20c349afb --- /dev/null +++ b/cmd/genautocomplete/genautocomplete_test.go @@ -0,0 +1,35 @@ +package genautocomplete + +import ( + "io/ioutil" + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCompletionBash(t *testing.T) { + tempFile, err := ioutil.TempFile("", "completion_bash") + assert.NoError(t, err) + defer func() { _ = tempFile.Close() }() + defer func() { _ = os.Remove(tempFile.Name()) }() + + bashCommandDefinition.Run(bashCommandDefinition, []string{tempFile.Name()}) + + bs, err := ioutil.ReadFile(tempFile.Name()) + assert.NoError(t, err) + assert.NotEmpty(t, string(bs)) +} + +func TestCompletionZsh(t *testing.T) { + tempFile, err := ioutil.TempFile("", "completion_zsh") + assert.NoError(t, err) + defer func() { _ = tempFile.Close() }() + defer func() { _ = os.Remove(tempFile.Name()) }() + + zshCommandDefinition.Run(zshCommandDefinition, []string{tempFile.Name()}) + + bs, err := ioutil.ReadFile(tempFile.Name()) + assert.NoError(t, err) + assert.NotEmpty(t, string(bs)) +} diff --git a/cmd/genautocomplete/genautocomplete_zsh.go b/cmd/genautocomplete/genautocomplete_zsh.go new file mode 100644 index 000000000..1a1f04dfe --- /dev/null +++ b/cmd/genautocomplete/genautocomplete_zsh.go @@ -0,0 +1,50 @@ +package genautocomplete + +import ( + "log" + "os" + + "github.com/ncw/rclone/cmd" + "github.com/spf13/cobra" +) + +func init() { + completionDefinition.AddCommand(zshCommandDefinition) +} + +var zshCommandDefinition = &cobra.Command{ + Use: "zsh [output_file]", + Short: `Output zsh completion script for rclone.`, + Long: ` +Generates a zsh autocompletion script for rclone. + +This writes to /usr/share/zsh/vendor-completions/_rclone by default so will +probably need to be run with sudo or as root, eg + + sudo rclone genautocomplete zsh + +Logout and login again to use the autocompletion scripts, or source +them directly + + autoload -U compinit && compinit + +If you supply a command line argument the script will be written +there. +`, + Run: func(command *cobra.Command, args []string) { + cmd.CheckArgs(0, 1, command, args) + out := "/usr/share/zsh/vendor-completions/_rclone" + if len(args) > 0 { + out = args[0] + } + outFile, err := os.Create(out) + if err != nil { + log.Fatal(err) + } + defer func() { _ = outFile.Close() }() + err = cmd.Root.GenZshCompletion(outFile) + if err != nil { + log.Fatal(err) + } + }, +} diff --git a/docs/content/commands/rclone.md b/docs/content/commands/rclone.md index 6f814a6f2..e2df05c73 100644 --- a/docs/content/commands/rclone.md +++ b/docs/content/commands/rclone.md @@ -1,5 +1,5 @@ --- -date: 2017-07-22T18:15:25+01:00 +date: 2017-08-20T10:49:45+02:00 title: "rclone" slug: rclone url: /commands/rclone/ @@ -156,7 +156,7 @@ rclone [flags] * [rclone dbhashsum](/commands/rclone_dbhashsum/) - Produces a Dropbbox hash file for all the objects in the path. * [rclone dedupe](/commands/rclone_dedupe/) - Interactively find duplicate files delete/rename them. * [rclone delete](/commands/rclone_delete/) - Remove the contents of path. -* [rclone genautocomplete](/commands/rclone_genautocomplete/) - Output bash completion script for rclone. +* [rclone genautocomplete](/commands/rclone_genautocomplete/) - Output completion script for a given shell. * [rclone gendocs](/commands/rclone_gendocs/) - Output markdown docs for rclone to the directory supplied. * [rclone listremotes](/commands/rclone_listremotes/) - List all the remotes in the config file. * [rclone ls](/commands/rclone_ls/) - List all the objects in the path with size and path. diff --git a/docs/content/commands/rclone_genautocomplete.md b/docs/content/commands/rclone_genautocomplete.md index 38790631a..f519a45dd 100644 --- a/docs/content/commands/rclone_genautocomplete.md +++ b/docs/content/commands/rclone_genautocomplete.md @@ -1,35 +1,25 @@ --- -date: 2017-07-22T18:15:25+01:00 +date: 2017-08-20T10:49:45+02:00 title: "rclone genautocomplete" slug: rclone_genautocomplete url: /commands/rclone_genautocomplete/ --- ## rclone genautocomplete -Output bash completion script for rclone. +Output completion script for a given shell. ### Synopsis -Generates a bash shell autocompletion script for rclone. +Generates a shell completion script for rclone. +Run with --help to list the supported shells. -This writes to /etc/bash_completion.d/rclone by default so will -probably need to be run with sudo or as root, eg - - sudo rclone genautocomplete - -Logout and login again to use the autocompletion scripts, or source -them directly - - . /etc/bash_completion - -If you supply a command line argument the script will be written -there. +### Options ``` -rclone genautocomplete [output_file] + -h, --help help for genautocomplete ``` ### Options inherited from parent commands @@ -126,6 +116,8 @@ rclone genautocomplete [output_file] ``` ### SEE ALSO -* [rclone](/commands/rclone/) - Sync files and directories to and from local and remote object stores - v1.37 +* [rclone](/commands/rclone/) - Sync files and directories to and from local and remote object stores - v1.37-099-gb78ecb15-zsh-completion +* [rclone genautocomplete bash](/commands/rclone_genautocomplete_bash/) - Output bash completion script for rclone. +* [rclone genautocomplete zsh](/commands/rclone_genautocomplete_zsh/) - Output zsh completion script for rclone. -###### Auto generated by spf13/cobra on 22-Jul-2017 +###### Auto generated by spf13/cobra on 20-Aug-2017 diff --git a/docs/content/commands/rclone_genautocomplete_bash.md b/docs/content/commands/rclone_genautocomplete_bash.md new file mode 100644 index 000000000..1c36655a0 --- /dev/null +++ b/docs/content/commands/rclone_genautocomplete_bash.md @@ -0,0 +1,137 @@ +--- +date: 2017-08-20T10:49:45+02:00 +title: "rclone genautocomplete bash" +slug: rclone_genautocomplete_bash +url: /commands/rclone_genautocomplete_bash/ +--- +## rclone genautocomplete bash + +Output bash completion script for rclone. + +### Synopsis + + + +Generates a bash shell autocompletion script for rclone. + +This writes to /etc/bash_completion.d/rclone by default so will +probably need to be run with sudo or as root, eg + + sudo rclone genautocomplete bash + +Logout and login again to use the autocompletion scripts, or source +them directly + + . /etc/bash_completion + +If you supply a command line argument the script will be written +there. + + +``` +rclone genautocomplete bash [output_file] [flags] +``` + +### Options + +``` + -h, --help help for bash +``` + +### Options inherited from parent commands + +``` + --acd-templink-threshold int Files >= this size will be downloaded via their tempLink. (default 9G) + --acd-upload-wait-per-gb duration Additional time per GB to wait after a failed complete upload to see if it appears. (default 3m0s) + --ask-password Allow prompt for password for encrypted configuration. (default true) + --b2-chunk-size int Upload chunk size. Must fit in memory. (default 96M) + --b2-test-mode string A flag string for X-Bz-Test-Mode header. + --b2-upload-cutoff int Cutoff for switching to chunked upload (default 190.735M) + --b2-versions Include old versions in directory listings. + --backup-dir string Make backups into hierarchy based in DIR. + --buffer-size int Buffer size when copying files. (default 16M) + --bwlimit BwTimetable Bandwidth limit in kBytes/s, or use suffix b|k|M|G or a full timetable. + --checkers int Number of checkers to run in parallel. (default 8) + -c, --checksum Skip based on checksum & size, not mod-time & size + --config string Config file. (default "/home/ncw/.rclone.conf") + --contimeout duration Connect timeout (default 1m0s) + -L, --copy-links Follow symlinks and copy the pointed to item. + --cpuprofile string Write cpu profile to file + --crypt-show-mapping For all files listed show how the names encrypt. + --delete-after When synchronizing, delete files on destination after transfering + --delete-before When synchronizing, delete files on destination before transfering + --delete-during When synchronizing, delete files during transfer (default) + --delete-excluded Delete files on dest excluded from sync + --drive-auth-owner-only Only consider files owned by the authenticated user. + --drive-chunk-size int Upload chunk size. Must a power of 2 >= 256k. (default 8M) + --drive-formats string Comma separated list of preferred formats for downloading Google docs. (default "docx,xlsx,pptx,svg") + --drive-list-chunk int Size of listing chunk 100-1000. 0 to disable. (default 1000) + --drive-shared-with-me Only show files that are shared with me + --drive-skip-gdocs Skip google documents in all listings. + --drive-trashed-only Only show files that are in the trash + --drive-upload-cutoff int Cutoff for switching to chunked upload (default 8M) + --drive-use-trash Send files to the trash instead of deleting permanently. + --dropbox-chunk-size int Upload chunk size. Max 150M. (default 128M) + -n, --dry-run Do a trial run with no permanent changes + --dump-auth Dump HTTP headers with auth info + --dump-bodies Dump HTTP headers and bodies - may contain sensitive info + --dump-filters Dump the filters to the output + --dump-headers Dump HTTP headers - may contain sensitive info + --exclude stringArray Exclude files matching pattern + --exclude-from stringArray Read exclude patterns from file + --fast-list Use recursive list if available. Uses more memory but fewer transactions. + --files-from stringArray Read list of source-file names from file + -f, --filter stringArray Add a file-filtering rule + --filter-from stringArray Read filtering patterns from a file + --gcs-location string Default location for buckets (us|eu|asia|us-central1|us-east1|us-east4|us-west1|asia-east1|asia-noetheast1|asia-southeast1|australia-southeast1|europe-west1|europe-west2). + --gcs-storage-class string Default storage class for buckets (MULTI_REGIONAL|REGIONAL|STANDARD|NEARLINE|COLDLINE|DURABLE_REDUCED_AVAILABILITY). + --ignore-checksum Skip post copy check of checksums. + --ignore-existing Skip all files that exist on destination + --ignore-size Ignore size when skipping use mod-time or checksum. + -I, --ignore-times Don't skip files that match size and time - transfer all files + --include stringArray Include files matching pattern + --include-from stringArray Read include patterns from file + --local-no-unicode-normalization Don't apply unicode normalization to paths and filenames + --log-file string Log everything to this file + --log-level string Log level DEBUG|INFO|NOTICE|ERROR (default "NOTICE") + --low-level-retries int Number of low level retries to do. (default 10) + --max-age string Don't transfer any file older than this in s or suffix ms|s|m|h|d|w|M|y + --max-depth int If set limits the recursion depth to this. (default -1) + --max-size int Don't transfer any file larger than this in k or suffix b|k|M|G (default off) + --memprofile string Write memory profile to file + --min-age string Don't transfer any file younger than this in s or suffix ms|s|m|h|d|w|M|y + --min-size int Don't transfer any file smaller than this in k or suffix b|k|M|G (default off) + --modify-window duration Max time diff to be considered the same (default 1ns) + --no-check-certificate Do not verify the server SSL certificate. Insecure. + --no-gzip-encoding Don't set Accept-Encoding: gzip. + --no-traverse Don't traverse destination file system on copy. + --no-update-modtime Don't update destination mod-time if files identical. + --old-sync-method Deprecated - use --fast-list instead + -x, --one-file-system Don't cross filesystem boundaries. + --onedrive-chunk-size int Above this size files will be chunked - must be multiple of 320k. (default 10M) + --onedrive-upload-cutoff int Cutoff for switching to chunked upload - must be <= 100MB (default 10M) + -q, --quiet Print as little stuff as possible + --retries int Retry operations this many times if they fail (default 3) + --s3-acl string Canned ACL used when creating buckets and/or storing objects in S3 + --s3-storage-class string Storage class to use when uploading S3 objects (STANDARD|REDUCED_REDUNDANCY|STANDARD_IA) + --size-only Skip based on size only, not mod-time or checksum + --stats duration Interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable) (default 1m0s) + --stats-log-level string Log level to show --stats output DEBUG|INFO|NOTICE|ERROR (default "INFO") + --stats-unit string Show data rate in stats as either 'bits' or 'bytes'/s (default "bytes") + --suffix string Suffix for use with --backup-dir. + --swift-chunk-size int Above this size files will be chunked into a _segments container. (default 5G) + --syslog Use Syslog for logging + --syslog-facility string Facility for syslog, eg KERN,USER,... (default "DAEMON") + --timeout duration IO idle timeout (default 5m0s) + --tpslimit float Limit HTTP transactions per second to this. + --tpslimit-burst int Max burst of transactions for --tpslimit. (default 1) + --track-renames When synchronizing, track file renames and do a server side move if possible + --transfers int Number of file transfers to run in parallel. (default 4) + -u, --update Skip files that are newer on the destination. + -v, --verbose count[=-1] Print lots more stuff (repeat for more) +``` + +### SEE ALSO +* [rclone genautocomplete](/commands/rclone_genautocomplete/) - Output completion script for a given shell. + +###### Auto generated by spf13/cobra on 20-Aug-2017 diff --git a/docs/content/commands/rclone_genautocomplete_zsh.md b/docs/content/commands/rclone_genautocomplete_zsh.md new file mode 100644 index 000000000..0b1c6bf2b --- /dev/null +++ b/docs/content/commands/rclone_genautocomplete_zsh.md @@ -0,0 +1,137 @@ +--- +date: 2017-08-20T10:49:45+02:00 +title: "rclone genautocomplete zsh" +slug: rclone_genautocomplete_zsh +url: /commands/rclone_genautocomplete_zsh/ +--- +## rclone genautocomplete zsh + +Output zsh completion script for rclone. + +### Synopsis + + + +Generates a zsh autocompletion script for rclone. + +This writes to /usr/share/zsh/vendor-completions/_rclone by default so will +probably need to be run with sudo or as root, eg + + sudo rclone genautocomplete zsh + +Logout and login again to use the autocompletion scripts, or source +them directly + + autoload -U compinit && compinit + +If you supply a command line argument the script will be written +there. + + +``` +rclone genautocomplete zsh [output_file] [flags] +``` + +### Options + +``` + -h, --help help for zsh +``` + +### Options inherited from parent commands + +``` + --acd-templink-threshold int Files >= this size will be downloaded via their tempLink. (default 9G) + --acd-upload-wait-per-gb duration Additional time per GB to wait after a failed complete upload to see if it appears. (default 3m0s) + --ask-password Allow prompt for password for encrypted configuration. (default true) + --b2-chunk-size int Upload chunk size. Must fit in memory. (default 96M) + --b2-test-mode string A flag string for X-Bz-Test-Mode header. + --b2-upload-cutoff int Cutoff for switching to chunked upload (default 190.735M) + --b2-versions Include old versions in directory listings. + --backup-dir string Make backups into hierarchy based in DIR. + --buffer-size int Buffer size when copying files. (default 16M) + --bwlimit BwTimetable Bandwidth limit in kBytes/s, or use suffix b|k|M|G or a full timetable. + --checkers int Number of checkers to run in parallel. (default 8) + -c, --checksum Skip based on checksum & size, not mod-time & size + --config string Config file. (default "/home/ncw/.rclone.conf") + --contimeout duration Connect timeout (default 1m0s) + -L, --copy-links Follow symlinks and copy the pointed to item. + --cpuprofile string Write cpu profile to file + --crypt-show-mapping For all files listed show how the names encrypt. + --delete-after When synchronizing, delete files on destination after transfering + --delete-before When synchronizing, delete files on destination before transfering + --delete-during When synchronizing, delete files during transfer (default) + --delete-excluded Delete files on dest excluded from sync + --drive-auth-owner-only Only consider files owned by the authenticated user. + --drive-chunk-size int Upload chunk size. Must a power of 2 >= 256k. (default 8M) + --drive-formats string Comma separated list of preferred formats for downloading Google docs. (default "docx,xlsx,pptx,svg") + --drive-list-chunk int Size of listing chunk 100-1000. 0 to disable. (default 1000) + --drive-shared-with-me Only show files that are shared with me + --drive-skip-gdocs Skip google documents in all listings. + --drive-trashed-only Only show files that are in the trash + --drive-upload-cutoff int Cutoff for switching to chunked upload (default 8M) + --drive-use-trash Send files to the trash instead of deleting permanently. + --dropbox-chunk-size int Upload chunk size. Max 150M. (default 128M) + -n, --dry-run Do a trial run with no permanent changes + --dump-auth Dump HTTP headers with auth info + --dump-bodies Dump HTTP headers and bodies - may contain sensitive info + --dump-filters Dump the filters to the output + --dump-headers Dump HTTP headers - may contain sensitive info + --exclude stringArray Exclude files matching pattern + --exclude-from stringArray Read exclude patterns from file + --fast-list Use recursive list if available. Uses more memory but fewer transactions. + --files-from stringArray Read list of source-file names from file + -f, --filter stringArray Add a file-filtering rule + --filter-from stringArray Read filtering patterns from a file + --gcs-location string Default location for buckets (us|eu|asia|us-central1|us-east1|us-east4|us-west1|asia-east1|asia-noetheast1|asia-southeast1|australia-southeast1|europe-west1|europe-west2). + --gcs-storage-class string Default storage class for buckets (MULTI_REGIONAL|REGIONAL|STANDARD|NEARLINE|COLDLINE|DURABLE_REDUCED_AVAILABILITY). + --ignore-checksum Skip post copy check of checksums. + --ignore-existing Skip all files that exist on destination + --ignore-size Ignore size when skipping use mod-time or checksum. + -I, --ignore-times Don't skip files that match size and time - transfer all files + --include stringArray Include files matching pattern + --include-from stringArray Read include patterns from file + --local-no-unicode-normalization Don't apply unicode normalization to paths and filenames + --log-file string Log everything to this file + --log-level string Log level DEBUG|INFO|NOTICE|ERROR (default "NOTICE") + --low-level-retries int Number of low level retries to do. (default 10) + --max-age string Don't transfer any file older than this in s or suffix ms|s|m|h|d|w|M|y + --max-depth int If set limits the recursion depth to this. (default -1) + --max-size int Don't transfer any file larger than this in k or suffix b|k|M|G (default off) + --memprofile string Write memory profile to file + --min-age string Don't transfer any file younger than this in s or suffix ms|s|m|h|d|w|M|y + --min-size int Don't transfer any file smaller than this in k or suffix b|k|M|G (default off) + --modify-window duration Max time diff to be considered the same (default 1ns) + --no-check-certificate Do not verify the server SSL certificate. Insecure. + --no-gzip-encoding Don't set Accept-Encoding: gzip. + --no-traverse Don't traverse destination file system on copy. + --no-update-modtime Don't update destination mod-time if files identical. + --old-sync-method Deprecated - use --fast-list instead + -x, --one-file-system Don't cross filesystem boundaries. + --onedrive-chunk-size int Above this size files will be chunked - must be multiple of 320k. (default 10M) + --onedrive-upload-cutoff int Cutoff for switching to chunked upload - must be <= 100MB (default 10M) + -q, --quiet Print as little stuff as possible + --retries int Retry operations this many times if they fail (default 3) + --s3-acl string Canned ACL used when creating buckets and/or storing objects in S3 + --s3-storage-class string Storage class to use when uploading S3 objects (STANDARD|REDUCED_REDUNDANCY|STANDARD_IA) + --size-only Skip based on size only, not mod-time or checksum + --stats duration Interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable) (default 1m0s) + --stats-log-level string Log level to show --stats output DEBUG|INFO|NOTICE|ERROR (default "INFO") + --stats-unit string Show data rate in stats as either 'bits' or 'bytes'/s (default "bytes") + --suffix string Suffix for use with --backup-dir. + --swift-chunk-size int Above this size files will be chunked into a _segments container. (default 5G) + --syslog Use Syslog for logging + --syslog-facility string Facility for syslog, eg KERN,USER,... (default "DAEMON") + --timeout duration IO idle timeout (default 5m0s) + --tpslimit float Limit HTTP transactions per second to this. + --tpslimit-burst int Max burst of transactions for --tpslimit. (default 1) + --track-renames When synchronizing, track file renames and do a server side move if possible + --transfers int Number of file transfers to run in parallel. (default 4) + -u, --update Skip files that are newer on the destination. + -v, --verbose count[=-1] Print lots more stuff (repeat for more) +``` + +### SEE ALSO +* [rclone genautocomplete](/commands/rclone_genautocomplete/) - Output completion script for a given shell. + +###### Auto generated by spf13/cobra on 20-Aug-2017 diff --git a/docs/content/docs.md b/docs/content/docs.md index d260d43d5..db55892a4 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -86,7 +86,7 @@ The main rclone commands with most used first * [rclone authorize](/commands/rclone_authorize/) - Remote authorization. * [rclone cat](/commands/rclone_cat/) - Concatenates any files and sends them to stdout. * [rclone copyto](/commands/rclone_copyto/) - Copy files from source to dest, skipping already copied -* [rclone genautocomplete](/commands/rclone_genautocomplete/) - Output bash completion script for rclone. +* [rclone genautocomplete](/commands/rclone_genautocomplete/) - Output shell completion scripts for rclone. * [rclone gendocs](/commands/rclone_gendocs/) - Output markdown docs for rclone to the directory supplied. * [rclone listremotes](/commands/rclone_listremotes/) - List all the remotes in the config file. * [rclone mount](/commands/rclone_mount/) - Mount the remote as a mountpoint. **EXPERIMENTAL**