fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Fabian BoehmRestyle fishscript and python946ecf235

master
8.4 KiB112 linesraw
1function __fail2ban_jails
2    # No need to deduplicate because fish will take care of that for us
3    path basename {,/usr/local}/etc/fail2ban/filter.d/*.{conf,local} | path change-extension ""
4end
5
6function __fail2ban_actions
7    # No need to deduplicate because fish will take care of that for us
8    path basename {,/usr/local}/etc/fail2ban/action.d/*.{conf,local} | path change-extension ""
9end
10
11# basic options
12complete -c fail2ban-client -s c -l conf -d "Configuration dir"
13complete -c fail2ban-client -s s -l socket -d "Socket path"
14complete -c fail2ban-client -s p -l pidfile -d "Pidfile path"
15complete -c fail2ban-client -l pname -d "Name of the process"
16complete -c fail2ban-client -l loglevel -d "loglevel of client" -xa "CRITICAL ERROR WARNING NOTICE INFO DEBUG TRACEDEBUG HEAVYDEBUG"
17complete -c fail2ban-client -l logtarget -d "Logging target" -a "stdout stderr syslog sysout" # or path
18complete -c fail2ban-client -l logtarget -d Syslogsocket -a auto # or path
19complete -c fail2ban-client -s d -d "Dump configuration"
20complete -c fail2ban-client -l dp -l dump-pretty -d "Dump configuration (pretty)"
21complete -c fail2ban-client -s t -l test -d "Test configuration"
22complete -c fail2ban-client -s i -d "Run in interactive mode"
23complete -c fail2ban-client -s v -d "Increase verbosity"
24complete -c fail2ban-client -s q -d "Decrease verbosity"
25complete -c fail2ban-client -s x -d "Force execution of server"
26complete -c fail2ban-client -s b -d "Start server in background (default)"
27complete -c fail2ban-client -s f -d "Start server in foreground"
28complete -c fail2ban-client -l str2sec -d "Convert time abbr format to secs"
29complete -c fail2ban-client -s h -l help -d "Display help message"
30complete -c fail2ban-client -s V -l version -d "Display client version"
31
32# subcommands
33complete -c fail2ban-client -n __fish_is_first_token -xa start -d "Start fail2ban server or jail"
34complete -c fail2ban-client -n __fish_is_first_token -xa restart -d "Restart server or jail"
35complete -c fail2ban-client -n __fish_is_first_token -xa reload -d "Reload server configuration"
36complete -c fail2ban-client -n __fish_is_first_token -xa stop -d "Stop fail2ban server or jail"
37complete -c fail2ban-client -n __fish_is_first_token -xa unban -d "Unban ip address(es)"
38complete -c fail2ban-client -n __fish_is_first_token -xa banned -d "List jails w/ their banned IPs"
39complete -c fail2ban-client -n __fish_is_first_token -xa status -d "Get server or jail status"
40complete -c fail2ban-client -n __fish_is_first_token -xa ping -d "Check if server is alive"
41complete -c fail2ban-client -n __fish_is_first_token -xa help -d "Prints usage synopsis"
42complete -c fail2ban-client -n __fish_is_first_token -xa version -d "Prints server version"
43complete -c fail2ban-client -n __fish_is_first_token -xa set
44complete -c fail2ban-client -n __fish_is_first_token -xa get
45complete -c fail2ban-client -n __fish_is_first_token -xa flushlogs -d "Flushes log files and reopens"
46complete -c fail2ban-client -n __fish_is_first_token -xa add
47
48complete -c fail2ban-client -n "__fish_seen_subcommand_from start" -xa "(__fail2ban_jails)"
49complete -c fail2ban-client -n "__fish_seen_subcommand_from stop" -xa "(__fail2ban_jails)"
50complete -c fail2ban-client -n "__fish_seen_subcommand_from status" -xa "(__fail2ban_jails)"
51complete -c fail2ban-client -n "__fish_seen_subcommand_from restart" -xa "(__fail2ban_jails)"
52complete -c fail2ban-client -n "__fish_seen_subcommand_from reload" -xa "(__fail2ban_jails)"
53complete -c fail2ban-client -n "__fish_seen_subcommand_from add" -xa "(__fail2ban_jails)"
54
55# restart options
56complete -c fail2ban-client -n "__fish_seen_subcommand_from restart" -l unban
57complete -c fail2ban-client -n "__fish_seen_subcommand_from reload" -l if-exists
58
59# reload options
60complete -c fail2ban-client -n "__fish_seen_subcommand_from restart" -l restart
61complete -c fail2ban-client -n "__fish_seen_subcommand_from reload" -l unban
62complete -c fail2ban-client -n "__fish_seen_subcommand_from reload" -l all
63complete -c fail2ban-client -n "__fish_seen_subcommand_from reload" -l if-exists
64
65# unban options
66complete -c fail2ban-client -n "__fish_seen_subcommand_from unban" -l all
67
68# get/set loglevel
69complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_prev_arg_in get" -xa loglevel -d "Get server log level"
70complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in set" -xa loglevel -d "Change server log level"
71complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in loglevel" -xa "CRITICAL ERROR WARNING NOTICE INFO DEBUG TRACEDEBUG HEAVYDEBUG"
72
73# get/set logtarget
74complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_prev_arg_in get" -xa logtarget -d "Get server log output"
75complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in set" -xa logtarget -d "Change server log output"
76complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in logtarget" -a "STDOUT STDERR SYSLOG SYSTEMD-JOURNAL" # or path
77
78# get/set syslogsocket
79complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_prev_arg_in get" -xa syslogsocket -d "Get server syslog socket"
80complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in set" -xa syslogsocket -d "Change server syslog socket"
81complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in syslogsocket" -a auto # or path
82
83# get/set dbfile
84complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_prev_arg_in get" -xa dbfile -d "Get server db path"
85complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in set" -xa dbfile -d "Change server db path"
86complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in dbfile" -a None # or path
87
88# get/set dbmaxmatches
89complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_prev_arg_in get" -xa dbmaxmatches -d "Get max matches stored per ticket"
90complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in set" -xa dbmaxmatches -d "Set max matches stored per ticket"
91complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in dbmaxmatches" -xa "(seq 0 100)"
92
93# get/set dbpurgeage
94complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_prev_arg_in get" -xa dbpurgeage -d "Get secs ban history will be kept"
95complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in set" -xa dbpurgeage -d "Set secs ban history will be kept"
96complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in dbpurgeage" -xa "(seq 0 30 3600)"
97
98# get/set <jail> options
99complete -c fail2ban-client -n "__fish_seen_subcommand_from set get" -n "__fish_prev_arg_in set get" -xa "(__fail2ban_jails)"
100complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_is_nth_token 3" -xa "idle ignoreself addignoreip delignoreip ignorecommand ignorecache addlogpath dellogpath logencoding addjournalmatch deljournalmatch addfailregex delfailregex bantime datepattern usedns attempt banip unbanip maxretry maxmatches maxlines addaction delaction action"
101complete -c fail2ban-client -n "__fish_seen_subcommand_from get" -n "__fish_is_nth_token 3" -xa "banned logpath logencoding journalmatch ignoreself ignoreip ignorecommand failregex ignoreregex findtime bantime datepattern usedns banip maxretry maxmatches maxlines actions action actionproperties actionmethods action"
102
103# complete actions for `get/set jail action/actionproperties/actionmethods` and `set jail addaction/delaction`
104complete -c fail2ban-client -n "__fish_seen_subcommand_from get set" -n "__fish_prev_arg_in action{,properties,methods}" -n "__fish_is_nth_token 4" -xa "(__fail2ban_actions)"
105complete -c fail2ban-client -n "__fish_seen_subcommand_from set" -n "__fish_prev_arg_in {add,del}action" -n "__fish_is_nth_token 4" -xa "(__fail2ban_actions)"
106
107# complete action commands for `get/set jail action <action>`
108complete -c fail2ban-client -n "__fish_seen_subcommand_from get set" -n "__fish_seen_subcommand_from action" -n "__fish_is_nth_token 5" -xa "actionstart actionstop actioncheck actionban actionunban timeout"
109
110# specific enumerable jail properties
111complete -c fail2ban-client -n "__fish_seen_subcommand_from get set" -n "__fish_prev_arg_in idle" -xa "on off"
112complete -c fail2ban-client -n "__fish_seen_subcommand_from get set" -n "__fish_prev_arg_in ignoreself" -xa "true false"