astraceroute: zsh: add auto-completion entry
[netsniff-ng.git] / trafgen.zsh
blob8fd1a372db5090ea4db85a6a86105eec2aa7a7e5
1 #compdef trafgen
3 # trafgen.zsh -- zsh completion function for trafgen
5 # Copyright (C) 2013 Hideo Hattori <hhatto.jp@gmail.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 as
9 # published by the Free Software Foundation.
11 typeset -A opt_args
12 local context state line
14 _cpu () {
15 _cpus=(${${(f)"$(grep processor /proc/cpuinfo | awk '{print $3}')"}})
16 compadd -a _cpus
19 _user_info () {
20 user_info=(${${(f)"$(awk -F':' '{print $3":"$1}' /etc/passwd)"}})
21 _describe -t usr "user info" user_info && ret=0
24 _group_info () {
25 group_info=(${${(f)"$(awk -F':' '{print $4":"$1}' /etc/passwd)"}})
26 _describe -t usr "group info" group_info && ret=0
29 _interfaces () {
30 _wanted interfaces expl 'network interface' \
31 _net_interfaces
32 _values "Pseudo-device that captures on all interfaces" "any"
35 _arguments -s -S \
36 "(-i -c --in --conf)"{-i,-c,--in,--conf}"[Packet configuration file/stdin]:input:_files" \
37 "(-o -d --out --dev)"{-o,-d,--out,--dev}"[Networking device i.e., eth0]:device:_interfaces" \
38 "(-p --cpp)"{-p,--cpp}"[Run packet config through C preprocessor]" \
39 "(-J --jumbo-support)"{-J,--jumbo-support}"[Support 64KB super jumbo frames (def: 2048B)]" \
40 "(-R --rfraw)"{-R,--rfraw}"[Inject raw 802.11 frames]" \
41 "(-s --smoke-test)"{-s,--smoke-test}"[Probe if machine survived fuzz-tested packet]" \
42 "(-n --num)"{-n,--num}"[Number of packets until exit (def: 0)]" \
43 "(-r --rand)"{-r,--rand}"[Randomize packet selection (def: round robin)]" \
44 "(-P --cpus)"{-P,--cpus}"[Specify number of forks(<= CPUs) (def: #CPUs)]:cpunum:_cpu" \
45 "(-t --gap)"{-t,--gap}"[Interpacket gap in us (approx)]" \
46 "(-S --ring-size)"{-S,--ring-size}"[Manually set mmap size (KiB/MiB/GiB)]:ringsize:" \
47 "(-k --kernel-pull)"{-k,--kernel-pull}"[Kernel pull from user interval in us (def: 10us)]:kernelpull:_gnu_generic" \
48 "(-E --seed)"{-E,--seed}"[Manually set srand(3) seed]" \
49 "(-u --user)"{-u,--user}"[Drop privileges and change to userid]:user:_user_info" \
50 "(-g --group)"{-g,--group}"[Drop privileges and change to groupid]:group:_group_info" \
51 "(-e --example)"{-e,--example}"[Show built-in packet config example]:" \
52 "(-V --verbose)"{-V,--verbose}"[Be more verbose]" \
53 "(-C --no-cpu-stats)"{-C,--no-cpu-stats}"[Do not print CPU time statistics on exit]" \
54 {-v,--version}"[Show version]:" \
55 {-h,--help}"[Guess what?!]:" \
56 "*::args:_gnu_generic"