mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Replace custom s3cmd completion functions with standard __fish_* functions
Per the discussion with @faho in #4332, replaced some custom completion
state detection functions with standard __fish_* functions used in other
completion sources.
(cherry picked from commit f706081ea4
)
This commit is contained in:
parent
f8f954bd5c
commit
97dd46306e
1 changed files with 72 additions and 87 deletions
|
@ -1,26 +1,11 @@
|
|||
# s3cmd
|
||||
|
||||
function __s3cmd_is_remote_path
|
||||
commandline -pct | string match -r -- "^s3://.*"
|
||||
commandline -pct | string match -q -r -- "^s3://.*"
|
||||
end
|
||||
|
||||
function __s3cmd_is_valid_remote_path
|
||||
commandline -pct | string match -r -- "^s3://.*?/.*"
|
||||
end
|
||||
|
||||
function __prev_tokens
|
||||
set __tokens (commandline -pco)
|
||||
for arg in $argv
|
||||
if echo $__tokens[-1] | string match $arg
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function __initial_command
|
||||
set __tokens (commandline -pco)
|
||||
string match (count $__tokens) 1
|
||||
commandline -pct | string match -q -r -- "^s3://.*?/.*"
|
||||
end
|
||||
|
||||
# Completions to allow for autocomplete of remote paths
|
||||
|
@ -28,49 +13,49 @@ complete -c s3cmd -f -n "__s3cmd_is_valid_remote_path" -a "(s3cmd ls (commandlin
|
|||
complete -c s3cmd -f -n "__s3cmd_is_remote_path"
|
||||
|
||||
# Supress file completions for initial command
|
||||
complete -c s3cmd -n "__initial_command" -f
|
||||
complete -c s3cmd -n "__fish_is_first_token" -f
|
||||
|
||||
# Available commands
|
||||
complete -c s3cmd -n "__initial_command" -a 'mb' --description 'Make bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'rb' --description 'Remove bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'ls' --description 'List objects or buckets'
|
||||
complete -c s3cmd -n "__initial_command" -a 'la' --description 'List all object in all buckets'
|
||||
complete -c s3cmd -n "__initial_command" -a 'put' --description 'Put file into bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'get' --description 'Get file from bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'del' --description 'Delete file from bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'rm' --description 'Delete file from bucket (alias for del)'
|
||||
complete -c s3cmd -n "__initial_command" -a 'restore' --description 'Restore file from Glacier storage'
|
||||
complete -c s3cmd -n "__initial_command" -a 'sync' --description 'Synchronize a directory tree to S3'
|
||||
complete -c s3cmd -n "__initial_command" -a 'du' --description 'Disk usage by buckets'
|
||||
complete -c s3cmd -n "__initial_command" -a 'info' --description 'Get various information about Buckets or Files'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cp' --description 'Copy object'
|
||||
complete -c s3cmd -n "__initial_command" -a 'modify' --description 'Modify object metadata'
|
||||
complete -c s3cmd -n "__initial_command" -a 'mv' --description 'Move object'
|
||||
complete -c s3cmd -n "__initial_command" -a 'setacl' --description 'Modify Access control list for Bucket or Files'
|
||||
complete -c s3cmd -n "__initial_command" -a 'setpolicy' --description 'Modify Bucket Policy'
|
||||
complete -c s3cmd -n "__initial_command" -a 'delpolicy' --description 'Delete Bucket Policy'
|
||||
complete -c s3cmd -n "__initial_command" -a 'setcors' --description 'Modify Bucket CORS'
|
||||
complete -c s3cmd -n "__initial_command" -a 'delcors' --description 'Delete Bucket CORS'
|
||||
complete -c s3cmd -n "__initial_command" -a 'payer' --description 'Modify Bucket Requester Pays policy'
|
||||
complete -c s3cmd -n "__initial_command" -a 'multipart' --description 'Show multipart uploads'
|
||||
complete -c s3cmd -n "__initial_command" -a 'abortmp' --description 'Abort a multipart upload'
|
||||
complete -c s3cmd -n "__initial_command" -a 'listmp' --description 'List parts of a multipart upload'
|
||||
complete -c s3cmd -n "__initial_command" -a 'accesslog' --description 'Enable/disable bucket access logging'
|
||||
complete -c s3cmd -n "__initial_command" -a 'sign' --description 'Sign arbitrary string using the secret key'
|
||||
complete -c s3cmd -n "__initial_command" -a 'signurl' --description 'Sign an S3 URL to provide limited public access with expiry'
|
||||
complete -c s3cmd -n "__initial_command" -a 'fixbucket' --description 'Fix invalid file names in a bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'ws-create' --description 'Create Website from bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'ws-delete' --description 'Delete Website'
|
||||
complete -c s3cmd -n "__initial_command" -a 'ws-info' --description 'Info about Website'
|
||||
complete -c s3cmd -n "__initial_command" -a 'expire' --description 'Set or delete expiration rule for the bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'setlifecycle' --description 'Upload a lifecycle policy for the bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'dellifecycle' --description 'Remove a lifecycle policy for the bucket'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cflist' --description 'List CloudFront distribution points'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cfinfo' --description 'Display CloudFront distribution point parameters'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cfcreate' --description 'Create CloudFront distribution point'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cfdelete' --description 'Delete CloudFront distribution point'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cfmodify' --description 'Change CloudFront distribution point parameters'
|
||||
complete -c s3cmd -n "__initial_command" -a 'cfinvalinfo' --description 'Display CloudFront invalidation request(s) status'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'mb' --description 'Make bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'rb' --description 'Remove bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'ls' --description 'List objects or buckets'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'la' --description 'List all object in all buckets'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'put' --description 'Put file into bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'get' --description 'Get file from bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'del' --description 'Delete file from bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'rm' --description 'Delete file from bucket (alias for del)'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'restore' --description 'Restore file from Glacier storage'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'sync' --description 'Synchronize a directory tree to S3'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'du' --description 'Disk usage by buckets'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'info' --description 'Get various information about Buckets or Files'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cp' --description 'Copy object'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'modify' --description 'Modify object metadata'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'mv' --description 'Move object'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'setacl' --description 'Modify Access control list for Bucket or Files'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'setpolicy' --description 'Modify Bucket Policy'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'delpolicy' --description 'Delete Bucket Policy'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'setcors' --description 'Modify Bucket CORS'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'delcors' --description 'Delete Bucket CORS'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'payer' --description 'Modify Bucket Requester Pays policy'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'multipart' --description 'Show multipart uploads'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'abortmp' --description 'Abort a multipart upload'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'listmp' --description 'List parts of a multipart upload'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'accesslog' --description 'Enable/disable bucket access logging'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'sign' --description 'Sign arbitrary string using the secret key'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'signurl' --description 'Sign an S3 URL to provide limited public access with expiry'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'fixbucket' --description 'Fix invalid file names in a bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'ws-create' --description 'Create Website from bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'ws-delete' --description 'Delete Website'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'ws-info' --description 'Info about Website'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'expire' --description 'Set or delete expiration rule for the bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'setlifecycle' --description 'Upload a lifecycle policy for the bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'dellifecycle' --description 'Remove a lifecycle policy for the bucket'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cflist' --description 'List CloudFront distribution points'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cfinfo' --description 'Display CloudFront distribution point parameters'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cfcreate' --description 'Create CloudFront distribution point'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cfdelete' --description 'Delete CloudFront distribution point'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cfmodify' --description 'Change CloudFront distribution point parameters'
|
||||
complete -c s3cmd -n "__fish_is_first_token" -a 'cfinvalinfo' --description 'Display CloudFront invalidation request(s) status'
|
||||
|
||||
# Created against s3cmd version 2.0
|
||||
complete -c s3cmd -s h -l help --description 'Show help and exit'
|
||||
|
@ -86,26 +71,26 @@ complete -c s3cmd -l no-ssl --description 'Don\'t use HTTPS'
|
|||
complete -c s3cmd -s e -l encrypt --description 'Encrypt files before uploading'
|
||||
complete -c s3cmd -l no-encrypt --description 'Don\'t encrypt files'
|
||||
complete -c s3cmd -s f -l force --description 'Force overwrite'
|
||||
complete -c s3cmd -l continue --description 'Resume partially downloaded file' -n "__prev_tokens get"
|
||||
complete -c s3cmd -l continue --description 'Resume partially downloaded file' -n "__fish_seen_subcommand_from get"
|
||||
complete -c s3cmd -l continue-put --description 'Resume partially uploaded files'
|
||||
complete -c s3cmd -l upload-id --description 'Resume multipart upload by UploadId'
|
||||
complete -c s3cmd -l skip-existing --description 'Skip existing files at destination' -n "__prev_tokens get sync"
|
||||
complete -c s3cmd -l skip-existing --description 'Skip existing files at destination' -n "__fish_seen_subcommand_from get sync"
|
||||
complete -c s3cmd -s r -l recursive --description 'Upload/download/delete recursively'
|
||||
complete -c s3cmd -l check-md5 --description 'Check MD5 sums (default)' -n "__prev_tokens sync"
|
||||
complete -c s3cmd -l no-check-md5 --description 'Skip MD5 sum check' -n "__prev_tokens sync"
|
||||
complete -c s3cmd -l check-md5 --description 'Check MD5 sums (default)' -n "__fish_seen_subcommand_from sync"
|
||||
complete -c s3cmd -l no-check-md5 --description 'Skip MD5 sum check' -n "__fish_seen_subcommand_from sync"
|
||||
complete -c s3cmd -s P -l acl-public --description 'Store with ACL read for all'
|
||||
complete -c s3cmd -l acl-private --description 'Store with private ACL'
|
||||
complete -c s3cmd -l acl-grant --description 'Grant permission to named user'
|
||||
complete -c s3cmd -l acl-revoke --description 'Revoke permission to named user'
|
||||
complete -c s3cmd -s D -l restore-days --description 'Days to keep restored file'
|
||||
complete -c s3cmd -l restore-priority --description 'S3 glacier restore priority'
|
||||
complete -c s3cmd -l delete-removed --description 'Delete objects not found locally' -n "__prev_tokens sync"
|
||||
complete -c s3cmd -l delete-removed --description 'Delete objects not found locally' -n "__fish_seen_subcommand_from sync"
|
||||
complete -c s3cmd -l no-delete-removed --description 'Don\'t delete dest objects'
|
||||
complete -c s3cmd -l delete-after --description 'Delete after upload' -n "__prev_tokens sync"
|
||||
complete -c s3cmd -l max-delete --description 'Delete no more than NUM files' -n "__prev_tokens del sync"
|
||||
complete -c s3cmd -l limit --description 'Max objects per response' -n "__prev_tokens ls la"
|
||||
complete -c s3cmd -l delete-after --description 'Delete after upload' -n "__fish_seen_subcommand_from sync"
|
||||
complete -c s3cmd -l max-delete --description 'Delete no more than NUM files' -n "__fish_seen_subcommand_from del sync"
|
||||
complete -c s3cmd -l limit --description 'Max objects per response' -n "__fish_seen_subcommand_from ls la"
|
||||
complete -c s3cmd -l add-destination --description 'Additional parallel upload'
|
||||
complete -c s3cmd -l delete-after-fetch --description 'Delete remotely after fetch' -n "__prev_tokens get sync"
|
||||
complete -c s3cmd -l delete-after-fetch --description 'Delete remotely after fetch' -n "__fish_seen_subcommand_from get sync"
|
||||
complete -c s3cmd -s p -l preserve --description 'Preserve FS attributes'
|
||||
complete -c s3cmd -l no-preserve --description 'Don\'t store FS attributes'
|
||||
complete -c s3cmd -l exclude --description 'Exclude GLOB matches'
|
||||
|
@ -120,11 +105,11 @@ complete -c s3cmd -l files-from --description 'Read source-file names from FILE'
|
|||
complete -c s3cmd -l region -l bucket-location --description 'Create bucket in region'
|
||||
complete -c s3cmd -l host --description 'S3 endpoint (default: s3.amazonaws.com)'
|
||||
complete -c s3cmd -l host-bucket --description 'DNS-style bucket+hostname:port template for bucket'
|
||||
complete -c s3cmd -l reduced-redundancy -l rr --description 'Store with reduced redundancy' -n "__prev_tokens put cp mv"
|
||||
complete -c s3cmd -l no-reduced-redundancy -l no-rr --description 'Store without reduced redundancy' -n "__prev_tokens put cp mv"
|
||||
complete -c s3cmd -l reduced-redundancy -l rr --description 'Store with reduced redundancy' -n "__fish_seen_subcommand_from put cp mv"
|
||||
complete -c s3cmd -l no-reduced-redundancy -l no-rr --description 'Store without reduced redundancy' -n "__fish_seen_subcommand_from put cp mv"
|
||||
complete -c s3cmd -l storage-class --description 'Store with STANDARD, STANDARD_IA, or REDUCED_REDUNDANCY'
|
||||
complete -c s3cmd -l access-logging-target-prefix --description 'Prefix for access logs' -n "__prev_tokens cfmodify accesslog"
|
||||
complete -c s3cmd -l no-access-logging --description 'Disable access logging' -n "__prev_tokens cfmodify accesslog"
|
||||
complete -c s3cmd -l access-logging-target-prefix --description 'Prefix for access logs' -n "__fish_seen_subcommand_from cfmodify accesslog"
|
||||
complete -c s3cmd -l no-access-logging --description 'Disable access logging' -n "__fish_seen_subcommand_from cfmodify accesslog"
|
||||
complete -c s3cmd -l default-mime-type --description 'Default MIME-type for objects'
|
||||
complete -c s3cmd -s M -l guess-mime-type --description 'Guess MIME-type'
|
||||
complete -c s3cmd -l no-guess-mime-type --description 'Don\'t guess MIME-type, use default'
|
||||
|
@ -139,25 +124,25 @@ complete -c s3cmd -l add-encoding-exts --description 'Add encoding to CSV extens
|
|||
complete -c s3cmd -l verbatim --description 'Use S3 name as-is'
|
||||
complete -c s3cmd -l disable-multipart --description 'No multipart on files larger than --multipart-chunk-size-mb'
|
||||
complete -c s3cmd -l multipart-chunk-size-mb --description 'Multipart upload chunk size'
|
||||
complete -c s3cmd -l list-md5 --description 'Include MD5 sums in bucket listings' -n "__prev_tokens ls"
|
||||
complete -c s3cmd -l list-md5 --description 'Include MD5 sums in bucket listings' -n "__fish_seen_subcommand_from ls"
|
||||
complete -c s3cmd -s H -l human-readable-sizes --description 'Print sizes in human-readable form'
|
||||
complete -c s3cmd -l ws-index --description 'Name of index-document' -n "__prev_tokens ws-create"
|
||||
complete -c s3cmd -l ws-error --description 'Name of error-document' -n "__prev_tokens ws-create"
|
||||
complete -c s3cmd -l expiry-date --description 'When expiration rule takes effect' -n "__prev_tokens expire"
|
||||
complete -c s3cmd -l expiry-days --description 'Days to expire' -n "__prev_tokens expire"
|
||||
complete -c s3cmd -l expiry-prefix --description 'Apply expiry to objects matching prefix' -n "__prev_tokens expire"
|
||||
complete -c s3cmd -l ws-index --description 'Name of index-document' -n "__fish_seen_subcommand_from ws-create"
|
||||
complete -c s3cmd -l ws-error --description 'Name of error-document' -n "__fish_seen_subcommand_from ws-create"
|
||||
complete -c s3cmd -l expiry-date --description 'When expiration rule takes effect' -n "__fish_seen_subcommand_from expire"
|
||||
complete -c s3cmd -l expiry-days --description 'Days to expire' -n "__fish_seen_subcommand_from expire"
|
||||
complete -c s3cmd -l expiry-prefix --description 'Apply expiry to objects matching prefix' -n "__fish_seen_subcommand_from expire"
|
||||
complete -c s3cmd -l progress --description 'Show progress (default on TTY)'
|
||||
complete -c s3cmd -l no-progress --description 'Don\'t show progress meter (default if non-TTY)'
|
||||
complete -c s3cmd -l stats --description 'Show file transfer stats'
|
||||
complete -c s3cmd -l enable --description 'Enable CloudFront distribution' -n "__prev_tokens cfmodify"
|
||||
complete -c s3cmd -l disable --description 'Disable CloudFront distribution' -n "__prev_tokens cfmodify"
|
||||
complete -c s3cmd -l cf-invalidate --description 'Invalidate CloudFront file' -n "__prev_tokens cfmodify"
|
||||
complete -c s3cmd -l cf-invalidate-default-index --description 'Invalidate default index' -n "__prev_tokens cfmodify"
|
||||
complete -c s3cmd -l cf-no-invalidate-default-index-root --description 'Don\'t invalidate default index' -n "__prev_tokens cfmodify"
|
||||
complete -c s3cmd -l cf-add-cname --description 'Add CNAME to CloudFront distribution' -n "__prev_tokens cfcreate cfmodify"
|
||||
complete -c s3cmd -l cf-remove-cname --description 'Remove CNAME from CloudFront distribution' -n "__prev_tokens cfmodify"
|
||||
complete -c s3cmd -l cf-comment --description 'Set COMMENT for CloudFront distribution' -n "__prev_tokens cfcreate cfmodify"
|
||||
complete -c s3cmd -l cf-default-root-object --description 'Set default root object' -n "__prev_tokens cfcreate cfmodify"
|
||||
complete -c s3cmd -l enable --description 'Enable CloudFront distribution' -n "__fish_seen_subcommand_from cfmodify"
|
||||
complete -c s3cmd -l disable --description 'Disable CloudFront distribution' -n "__fish_seen_subcommand_from cfmodify"
|
||||
complete -c s3cmd -l cf-invalidate --description 'Invalidate CloudFront file' -n "__fish_seen_subcommand_from cfmodify"
|
||||
complete -c s3cmd -l cf-invalidate-default-index --description 'Invalidate default index' -n "__fish_seen_subcommand_from cfmodify"
|
||||
complete -c s3cmd -l cf-no-invalidate-default-index-root --description 'Don\'t invalidate default index' -n "__fish_seen_subcommand_from cfmodify"
|
||||
complete -c s3cmd -l cf-add-cname --description 'Add CNAME to CloudFront distribution' -n "__fish_seen_subcommand_from cfcreate cfmodify"
|
||||
complete -c s3cmd -l cf-remove-cname --description 'Remove CNAME from CloudFront distribution' -n "__fish_seen_subcommand_from cfmodify"
|
||||
complete -c s3cmd -l cf-comment --description 'Set COMMENT for CloudFront distribution' -n "__fish_seen_subcommand_from cfcreate cfmodify"
|
||||
complete -c s3cmd -l cf-default-root-object --description 'Set default root object' -n "__fish_seen_subcommand_from cfcreate cfmodify"
|
||||
complete -c s3cmd -s v -l verbose --description 'Verbose output'
|
||||
complete -c s3cmd -s d -l debug --description 'Debug output'
|
||||
complete -c s3cmd -l version --description 'Show version'
|
||||
|
@ -172,7 +157,7 @@ complete -c s3cmd -l no-check-hostname --description 'Don\'t validate SSL hostna
|
|||
complete -c s3cmd -l signature-v2 --description 'Use AWS Signature version 2'
|
||||
complete -c s3cmd -l limit-rate --description 'Limit upload or download speed (bytes/sec)'
|
||||
complete -c s3cmd -l requester-pays --description 'Set REQUESTER PAYS for operations'
|
||||
complete -c s3cmd -s l -l long-listing --description 'Produce long listing' -n "__prev_tokens ls"
|
||||
complete -c s3cmd -s l -l long-listing --description 'Produce long listing' -n "__fish_seen_subcommand_from ls"
|
||||
complete -c s3cmd -l stop-on-error --description 'Stop on error in transfer'
|
||||
complete -c s3cmd -l content-disposition --description 'Provide Content-Disposition for signed URLs'
|
||||
complete -c s3cmd -l content-type --description 'Provide Content-Type for signed URLs'
|
||||
|
|
Loading…
Reference in a new issue