|
| 1 | +#compdef enma |
| 2 | + |
| 3 | +_enma() { |
| 4 | + local context state state_descr line |
| 5 | + typeset -A opt_args |
| 6 | + |
| 7 | + local -a subcommands |
| 8 | + subcommands=( |
| 9 | + 'init:Initialize configuration' |
| 10 | + 'hotload:Watch & reload daemon' |
| 11 | + 'watch:Watch & run commands' |
| 12 | + '--help:Show help' |
| 13 | + '--version:Show version' |
| 14 | + '--config:Define enma.toml' |
| 15 | + ) |
| 16 | + |
| 17 | + _arguments -C \ |
| 18 | + '1:command:->subcmd' \ |
| 19 | + '*::options:->args' |
| 20 | + |
| 21 | + case $state in |
| 22 | + subcmd) |
| 23 | + _describe 'subcommand' subcommands |
| 24 | + ;; |
| 25 | + args) |
| 26 | + case $words[1] in |
| 27 | + init) |
| 28 | + _values 'init options' \ |
| 29 | + '--help[Show help]' \ |
| 30 | + '--mode[Specify mode <hotload|watch|enmaignore>]:mode:(hotload watch enmaignore)' \ |
| 31 | + '--file[Specify output config file]:file:_files' |
| 32 | + ;; |
| 33 | + hotload) |
| 34 | + if [[ "$OSTYPE" == (linux*|darwin*|freebsd*|openbsd*|netbsd*) ]]; then |
| 35 | + _values 'hotload options' \ |
| 36 | + '--help[Show help]' \ |
| 37 | + '--daemon[Daemon command]:cmd:_command_names' \ |
| 38 | + '--build[Build command]:cmd:_command_names' \ |
| 39 | + '--signal[ (optional) signal to stop daemon command]:sig:( SIGTERM SIGKILL SIGHUP SIGUSR1 SIGUSR2 SIGINT )' \ |
| 40 | + '--watch-dir[ (optional) Directories to watch]:dir:_files -/' \ |
| 41 | + '--pre-build[ (optional) Pre-build command]:cmd:_command_names' \ |
| 42 | + '--post-build[ (optional) Post-build command]:cmd:_command_names' \ |
| 43 | + '--working-dir[ (optional) Working directory]:dir:_files -/' \ |
| 44 | + '--placeholder[ (optional) Placeholder token]:token:' \ |
| 45 | + '--args-path-style[ (optional) Filepath style]:style:(dir base ext)' \ |
| 46 | + '--build-at-start[ (optional) Build at startup]:bool:(on off)' \ |
| 47 | + '--check-content-diff[ (optional) Only on content change]:bool:(on off)' \ |
| 48 | + '--absolute-path[ (optional) Use absolute path]:bool:(on off)' \ |
| 49 | + '--timeout[ (optional) Timeout duration]:string:' \ |
| 50 | + '--delay[ (optional) Delay after build]:string:' \ |
| 51 | + '--retry[ (optional) Retry count]:int:' \ |
| 52 | + '--pattern-regex[ (optional) Regex to match files]:regex:' \ |
| 53 | + '--include-ext[ (optional) File extensions to include]' \ |
| 54 | + '--exclude-ext[ (optional) File extensions to exclude]' \ |
| 55 | + '--exclude-dir[ (optional) Dirs to exclude]:dir:_files -/' \ |
| 56 | + '--ignore-dir-regex[ (optional) Dir ignore regex]' \ |
| 57 | + '--ignore-file-regex[ (optional) File ignore regex]' \ |
| 58 | + '--default-ignores[ (optional) Specify default ignore volume <max|min|none>]:mode:(maximum minimal none)' \ |
| 59 | + '--enmaignore[ (optional) Ignore file list]:file:_files' \ |
| 60 | + '--logs[ (optional) Log file]:file:_files' \ |
| 61 | + '--pid[ (optional) PID file]:file:_files' |
| 62 | + else |
| 63 | + _values 'hotload options' \ |
| 64 | + '--help[Show help]' \ |
| 65 | + '--daemon[Daemon command]:cmd:_command_names' \ |
| 66 | + '--build[Build command]:cmd:_command_names' \ |
| 67 | + '--signal[ (optional) signal to stop daemon command]:sig:( SIGTERM SIGKILL SIGHUP SIGINT )' \ |
| 68 | + '--watch-dir[ (optional) Directories to watch]:dir:_files -/' \ |
| 69 | + '--pre-build[ (optional) Pre-build command]:cmd:_command_names' \ |
| 70 | + '--post-build[ (optional) Post-build command]:cmd:_command_names' \ |
| 71 | + '--working-dir[ (optional) Working directory]:dir:_files -/' \ |
| 72 | + '--placeholder[ (optional) Placeholder token]:token:' \ |
| 73 | + '--args-path-style[ (optional) Filepath style]:style:(dir base ext)' \ |
| 74 | + '--build-at-start[ (optional) Build at startup]:bool:(on off)' \ |
| 75 | + '--check-content-diff[ (optional) Only on content change]:bool:(on off)' \ |
| 76 | + '--absolute-path[ (optional) Use absolute path]:bool:(on off)' \ |
| 77 | + '--timeout[ (optional) Timeout duration]:string:' \ |
| 78 | + '--delay[ (optional) Delay after build]:string:' \ |
| 79 | + '--retry[ (optional) Retry count]:int:' \ |
| 80 | + '--pattern-regex[ (optional) Regex to match files]:regex:' \ |
| 81 | + '--include-ext[ (optional) File extensions to include]' \ |
| 82 | + '--exclude-ext[ (optional) File extensions to exclude]' \ |
| 83 | + '--exclude-dir[ (optional) Dirs to exclude]:dir:_files -/' \ |
| 84 | + '--ignore-dir-regex[ (optional) Dir ignore regex]' \ |
| 85 | + '--ignore-file-regex[ (optional) File ignore regex]' \ |
| 86 | + '--default-ignores[ (optional) Specify default ignore volume <max|min|none>]:mode:(maximum minimal none)' \ |
| 87 | + '--enmaignore[ (optional) Ignore file list]:file:_files' \ |
| 88 | + '--logs[ (optional) Log file]:file:_files' \ |
| 89 | + '--pid[ (optional) PID file]:file:_files' |
| 90 | + fi |
| 91 | + ;; |
| 92 | + watch) |
| 93 | + _values 'watch options' \ |
| 94 | + '--help[Show help]' \ |
| 95 | + '--command[Command to run]:cmd:_command_names' \ |
| 96 | + '--watch-dir[ (optional) Directories to watch]:dir:_files -/' \ |
| 97 | + '--pre-cmd[ (optional) Pre-command]:cmd:_command_names' \ |
| 98 | + '--post-cmd[ (optional) Post-command]:cmd:_command_names' \ |
| 99 | + '--working-dir[ (optional) Working directory]:dir:_files -/' \ |
| 100 | + '--placeholder[ (optional) Placeholder token]:token:' \ |
| 101 | + '--args-path-style[ (optional) Filepath style]:style:(dir base ext full)' \ |
| 102 | + '--check-content-diff[ (optional) Only on content change]:bool:(on off)' \ |
| 103 | + '--absolute-path[ (optional) Use absolute path]:bool:(on off)' \ |
| 104 | + '--timeout[ (optional) Timeout duration]:string:' \ |
| 105 | + '--delay[ (optional) Delay duration]:string:' \ |
| 106 | + '--retry[ (optional) Retry count]:int:' \ |
| 107 | + '--pattern-regex[ (optional) Regex to match files]:regex:' \ |
| 108 | + '--include-ext[ (optional) File extensions to include]' \ |
| 109 | + '--exclude-ext[ (optional) File extensions to exclude]' \ |
| 110 | + '--exclude-dir[ (optional) Dirs to exclude]:dir:_files -/' \ |
| 111 | + '--ignore-dir-regex[ (optional) Dir ignore regex]' \ |
| 112 | + '--ignore-file-regex[ (optional) File ignore regex]' \ |
| 113 | + '--enmaignore[ (optional) Ignore file list]:file:_files' \ |
| 114 | + '--logs[ (optional) Log file]:file:_files' \ |
| 115 | + '--pid[ (optional) PID file]:file:_files' |
| 116 | + ;; |
| 117 | + *) |
| 118 | + _message 'No subcommand matched.' |
| 119 | + ;; |
| 120 | + esac |
| 121 | + ;; |
| 122 | + esac |
| 123 | +} |
| 124 | + |
| 125 | +compdef _enma enma |
| 126 | +return 0 |
0 commit comments