about summary refs log tree commit diff
path: root/Completion/Linux
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Linux')
-rw-r--r--Completion/Linux/Command/_btrfs142
1 files changed, 138 insertions, 4 deletions
diff --git a/Completion/Linux/Command/_btrfs b/Completion/Linux/Command/_btrfs
index 88443e278..c8f87ef70 100644
--- a/Completion/Linux/Command/_btrfs
+++ b/Completion/Linux/Command/_btrfs
@@ -1,4 +1,5 @@
 #compdef btrfs
+# based on Btrfs v3.12+20131125
 
 local curcontext="$curcontext" curstate state line expl grp cmd ret=1
 local -a cmds_1 cmds_2 cmds_3 cmds_4 cmds_5 cmds_6 cmds_7 cmds_8 cmds_9 cmds_10
@@ -38,9 +39,65 @@ while (( $#state )); do
       : $words
       local grp=${groups[(i)$words[2]*]}
       : $grp
-      (( grp && grp < 7 )) || return 1
+      (( grp && grp <= 14 )) || return 1
       curcontext="${curcontext%:*:*}:$service-${groups[grp]}:"
-      _wanted commands expl command compadd -a cmds_$grp && ret=0
+      case $grp in
+        11)
+          # btrfs check
+          args+=(
+            {-s,--support}'[specify superblock]:superblock: _message "superblock"'
+            '--repair[try to repair the filesystem]'
+            '--init-csum-tree[create a new CRC tree]'
+            '--init-extent-tree[create a new extent tree]'
+            '1:path:_files -/'
+            )
+          ;|
+        12)
+          # btrfs replace
+          args+=(
+            '-s[get snapshots]'
+            '-x[get extended attributes]'
+            '-v[verbose]'
+            '-i[ignore errors]'
+            '-o[overwrite]'
+            '-t[tree location]:tree:_message "tree location"'
+            '-f[filesystem location]:filesystem:_message "filesystem location"'
+            '-u[super mirror]:mirror:_message "super mirror"'
+            '-r[root objectid]:objectid:_message "root objectid"'
+            '-d[find dir]'
+            '-l[list tree roots]'
+            '--path-regex[restore matching filenames]:regex:_message "regex"'
+            '1:device:_files -/'
+            '2:path:_files -/'
+            )
+          ;|
+        13)
+          # btrfs send
+          args+=(
+            '*-v[verbose mode]'
+            '-p[send incremental stream]:parent:_files -/'
+            '*-c[use snapshot as clone source]:clone:_files -/'
+            '-f[output file]:file:_files'
+            '1:subvol:_files -/'
+            )
+          ;|
+        14)
+          # btrfs receive
+          args+=(
+            '*-v[verbose mode]'
+            '-f[input file]:file: _files'
+            '-e[terminate after <end cmd>]'
+            '1:mount:->mounts'
+            )
+          ;|
+        <11-14>)
+          (( CURRENT-- )); shift words; curcontext="${curcontext%:*:*}:$service-${group[grp]}:"
+          _arguments -C "$args[@]" && ret=0
+          ;;
+        <0-10>)
+          _wanted commands expl command compadd -a cmds_$grp && ret=0
+          ;;
+      esac
     ;;
     args)
       : $words
@@ -64,8 +121,31 @@ while (( $#state )); do
           ;;
         subvolume:create) args+=( '1:destination:->mounts' );;
         subvolume:delete) args+=( '1:subvolume:_files -/' );;
-        subvolume:snapshot) args+=( '-r[readonly snapshot]' '1:snapshot:_files -/' );;
-        subvolume:list) args+=( '-p[include parent ID in output]' '1:path:->mounts' );;
+        subvolume:snapshot) 
+          args+=( 
+            '-r[readonly snapshot]'
+            '*-i[assign to qgroup]:qgroup: _message "qgroup"'
+            '1:snapshot:_files -/' 
+          )
+          ;;
+        subvolume:list) 
+          args+=( 
+            '-p[include parent ID in output]'
+            '-a[include all subvolumes]'
+            '-c[include ogeneration of the subvolume]'
+            '-g[include generation of the subvolume]'
+            '-o[include only subvolumes below the path]'
+            '-u[include UUID of subvolume]'
+            '-q[include parent UUID of subvolume]'
+            '-t[print results as a table]'
+            '-s[list only snapshot subvolumes]'
+            '-r[list only readonly subvolumes]'
+            '-G[subvolume generation is more or less than]:gen: _guard "(|+|-)[0-9]#"'
+            '-C[subvolume ogeneration is more or less than]:ogen: _guard "(|+|-)[0-9]#"'
+            '--sort=-[list in order]:sort:_values -s "," sort rootid gen ogen path'
+            '1:path:->mounts'
+            )
+            ;;
         subvolume:set-default) args+=( '1:id:_guard "[0-9]#" id' '2:path:->mounts' );;
         subvolume:get-default) args+=( '1:path:_files -/' );;
         subvolume:find-new) args+=( '1:subvol:_files -/' '2:lastgen: _message "last gen"' );;
@@ -131,7 +211,53 @@ while (( $#state )); do
             ;;
         balance:status) args+=( '-v[verbose mode]' '2:path:_files -/' );;
         balance:(pause|cancel|resume)) args+=( '2:path:_files -/' );;
+        quota:(enable|disable)) args+=( '1:path:_files -/' );;
+        quota:rescan) 
+          args+=( 
+            '-s[show status of currently running rescan]'
+            '-w[wait for rescan to finish]'
+            '1:path:_files -/' 
+            )
+            ;;
+        qgroup:(assign|remove)) args+=( '1:source path:_files -/' 
+          '2:destination path:_files -/' '3:path:_files -/' );;
+        qgroup:(create|destroy)) args+=( '1:qgroupid:' '2:path:_files -/' );; 
+        qgroup:show) 
+          args+=( 
+            '-p[print parent qgroup id]'
+            '-c[print child qgroup id]'
+            '-r[print max referenced size of qgroup]'
+            '-e[print max exclusive size of qgroup]'
+            '-F[list impacted qgroups\(include ancestral qgroups\)]'
+            '-f[list impacted qgroups\(exclude ancestral qgroups\)]'
+            '--sort=-[sort qgroups]:sort:_values -s , sort \
+              qgroupid rfer excl max_rfer max_excl' 
+            '1:path:_files -/'
+            )
+            ;;
+        qgroup:limit) 
+           args+=( 
+             '-c[limit amount of data after compression]' 
+             '-e[limit space exclusively to qgroup]'
+             ':size or none: _message "size or none"'
+             ':qgroup id or path:_files -/'
+             ':path:_files -/'
+             )
+             ;;
+        replace:start)
+          args+=(
+            '-r[read from <srcdev> only]:srcdev:_files'
+            '-f[force overwriting of target]'
+            '-B[do not background]'
+            ':srcdev or devid:_files'
+            ':target:_files'
+            ':path:->mounts'
+            )
+            ;;
+        replace:status) args+=( '-1[print once]' ':path:->mounts' );;
+        replace:cancel) args+=( ':path:->mounts' );;
         inspect*:inode*) args+=( '-v[verbose mode]' '1:inode:_files' '2:path:_files -/' );;
+        inspect*:subvol*) args+=( '-v[verbose mode]' '1:subvolid:_guard "[0-9]#" subvolume id' '2:path:_files -/' );;
         inspect*:logical*)
           args+=(
             '-v[verbose mode]'
@@ -141,6 +267,14 @@ while (( $#state )); do
             '2:filesystem path:_files -/'
             )
             ;;
+        inspect*:rootid) args+=( '1:path:_files -/' );;
+        rescue:(chunk|super)-recover)
+          args+=(
+            '-y[assume yes to every question]'
+            '-v[verbose mode]'
+            )
+            [[ ${${(P)group}[cmd]} == chunk-recover ]] && args+=('-h[display help]')
+            ;;
         subvolume:get-default) ;&
         *:sync) ;&
         *:df) args+=( '1:path:->mounts' );;