|
| 1 | +#compdef mkdwarfs |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | +# Author: Ahmad Khalifa |
| 5 | +# |
| 6 | +# zsh completion for mkdwarfs |
| 7 | +# |
| 8 | +# synopsis |
| 9 | +# mkdwarfs [OPTIONS...] |
| 10 | +# |
| 11 | + |
| 12 | +local context state line ret=1 |
| 13 | + |
| 14 | +# TODO: unreliable? maybe not if app keeps the two groups intact. |
| 15 | +__mkdwarfs_list_comp_algos() |
| 16 | +{ |
| 17 | + # extract algorithms block |
| 18 | + # trim algo leading space, delete algo args, remove empty line |
| 19 | + # delete algo descriptions |
| 20 | + # double print with trailing '\:' except 'null' |
| 21 | + mkdwarfs -H | \ |
| 22 | + sed -e '1,/Compression algorithms/d;/Categories:/,$d' \ |
| 23 | + -e 's/^[ ]\{1,2\}//;/^ /d;/^$/d' \ |
| 24 | + -e 's/ .*$//' \ |
| 25 | + -ne 'p;/null/!s/$/\\:/p' |
| 26 | +} |
| 27 | + |
| 28 | +__mkdwarfs_additional_options() |
| 29 | +{ |
| 30 | + if [[ "$(mkdwarfs -h | grep -e ' *--man')" ]]; then |
| 31 | + echo "--man" |
| 32 | + fi |
| 33 | +} |
| 34 | + |
| 35 | +_arguments -S \ |
| 36 | + "--bloom-filter-size" \ |
| 37 | + "--categorize=-:cattype:_values -s , cattype fits pcmaudio incompressible" \ |
| 38 | + "--change-block-size" \ |
| 39 | + "--chmod" \ |
| 40 | + "--compress-niceness" \ |
| 41 | + "--debug-filter" \ |
| 42 | + "--file-hash:hashfnc:" \ |
| 43 | + "--header" \ |
| 44 | + "--history-compression:algos:($(__mkdwarfs_list_comp_algos))" \ |
| 45 | + "--hotness-list" \ |
| 46 | + "--incompressible-block-size" \ |
| 47 | + "--incompressible-fragments" \ |
| 48 | + "--incompressible-min-input-size" \ |
| 49 | + "--incompressible-ratio" \ |
| 50 | + "--incompressible-zstd-level" \ |
| 51 | + "--input-list[file containing list of file paths relative to root directory or - for stdin]:filename:_files" \ |
| 52 | + "--keep-all-times[save atime and ctime in addition to mtime]" \ |
| 53 | + "--log-level:level:(error warn info verbose debug trace)" \ |
| 54 | + "--log-with-context" \ |
| 55 | + "--max-similarity-size" \ |
| 56 | + "--metadata-compression:algos:($(__mkdwarfs_list_comp_algos))" \ |
| 57 | + "--no-category-metadata" \ |
| 58 | + "--no-category-names" \ |
| 59 | + "--no-create-timestamp" \ |
| 60 | + "--no-history" \ |
| 61 | + "--no-history-command-line" \ |
| 62 | + "--no-history-timestamps" \ |
| 63 | + "--no-metadata-version-history" \ |
| 64 | + "--no-progress" \ |
| 65 | + "--no-section-index" \ |
| 66 | + "--num-scanner-workers" \ |
| 67 | + "--num-segmenter-workers" \ |
| 68 | + "--order" \ |
| 69 | + "--progress=-:progress:(ascii none simple unicode)" \ |
| 70 | + "--rebuild-metadata" \ |
| 71 | + "--recompress:level:(none block metadata all)" \ |
| 72 | + "--recompress-categories" \ |
| 73 | + "--remove-empty-dirs" \ |
| 74 | + "--remove-header" \ |
| 75 | + "--schema-compression:algos:($(__mkdwarfs_list_comp_algos))" \ |
| 76 | + "--set-group[group (gid) for whole file system]" \ |
| 77 | + "--set-owner[owner (uid) for whole file system]" \ |
| 78 | + "--set-time[timestamp for whole file system (unixtime or 'now')]" \ |
| 79 | + "--time-resolution" \ |
| 80 | + "--with-devices" \ |
| 81 | + "--with-specials" \ |
| 82 | + {-B,--max-lookback-blocks}"[blocks to scan for segments]" \ |
| 83 | + {-C,--compression}"[block compression algorithm]:algos:($(__mkdwarfs_list_comp_algos))" \ |
| 84 | + {-F,--filter} \ |
| 85 | + {-f,--force}"[force overwrite of existing output image]" \ |
| 86 | + {-h,--help}"[help message]" \ |
| 87 | + {-H,--long-help}"[full help message]" \ |
| 88 | + {-i,--input}"[path to root directory or source filesystem]:directory:_files -/" \ |
| 89 | + {-l,--compress-level}"[compression level (0=fast, 9=best)]:level:(0 1 2 3 4 5 6 7 8 9)" \ |
| 90 | + {-L,--memory-limit} \ |
| 91 | + {-N,--num-workers}"[number of writer (compression) worker threads]" \ |
| 92 | + {-o,--output}"[filesystem output name or - for stdout]:filename:_files" \ |
| 93 | + {-P,--pack-metadata}":packtype:_values packtype auto all none \ |
| 94 | + chunk_table directories shared_files names names_index symlinks \ |
| 95 | + symlinks_index force plain" \ |
| 96 | + {-S,--block-size-bits} \ |
| 97 | + {-W,--window-size} \ |
| 98 | + {-w,--window-step} \ |
| 99 | + $(__mkdwarfs_additional_options) && ret=0 |
| 100 | + |
| 101 | +return ret |
0 commit comments