chiark / gitweb /
440e35d05bc72735aa682dd34a2c4de73ca96269
[elogind.git] / shell-completion / zsh / _journalctl
1 #compdef journalctl
2
3 _outputmodes() {
4     local -a _output_opts
5     _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
6     _describe -t output 'output mode' _output_opts || compadd "$@"
7 }
8
9 _list_fields() {
10     local -a journal_fields
11     journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
12                     ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
13                     _{P,U,G}ID _COMM _EXE _CMDLINE
14                     _AUDIT_{SESSION,LOGINUID}
15                     _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
16                     _SYSTEMD_USER_UNIT
17                     _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
18                     _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
19                     _KERNEL_{DEVICE,SUBSYSTEM}
20                     _UDEV_{SYSNAME,DEVNODE,DEVLINK}
21                     __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
22     _describe 'possible fields' journal_fields
23 }
24
25 _journal_none() {
26     local -a _commands _files
27     _commands=( ${(f)"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
28     _alternative : \
29         'files:/dev files:_files -W /dev -P /dev/' \
30         "commands:commands:($_commands[@])" \
31         'fields:fields:_list_fields'
32 }
33
34 _journal_fields() {
35     local -a _fields cmd
36     cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
37     _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
38     typeset -U _fields
39     _describe 'possible values' _fields
40 }
41
42 _arguments -s \
43     {-h,--help}'[Show this help]' \
44     '--version[Show package version]' \
45     '--no-pager[Do not pipe output into a pager]' \
46     {-l,--full}'[Show long fields in full]' \
47     {-a,--all}'[Show all fields, including long and unprintable]' \
48     {-f,--follow}'[Follow journal]' \
49     {-e,--pager-end}'[Jump to the end of the journal in the pager]' \
50     {-n,--lines=}'[Number of journal entries to show]:integer' \
51     '--no-tail[Show all lines, even in follow mode]' \
52     {-r,--reverse}'[Reverse output]' \
53     {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \
54     {-x,--catalog}'[Show explanatory texts with each log line]' \
55     {-q,--quiet}"[Don't show privilege warning]" \
56     {-m,--merge}'[Show entries from all available journals]' \
57     {-b,--boot}'[Show entries from the specified boot only]' \
58     {-k,--dmesg}'[Show only kernel messages, Implies -b]' \
59     {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
60     '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
61     {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
62     {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
63     '--after-cursor=[Start showing entries from the location in the journal after the cursor]:cursors:_journal_fields __CURSORS' \
64     '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
65     '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
66     {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
67     '--system[Show system and kernel messages]' \
68     '--user[Show messages from user services]' \
69     {-D,--directory=}'[Show journal files from directory]:directories:_directories' \
70     '--file=[Operate on specified journal files]:file:_files' \
71     '--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
72     '--new-id128[Generate a new 128 Bit ID]' \
73     '--header[Show journal header information]' \
74     '--disk-usage[Show total disk usage]' \
75     '--list-catalog[List messages in catalog]' \
76     '--dump-catalog[Dump messages in catalog]' \
77     '--update-catalog[Update binary catalog database]' \
78     '--setup-keys[Generate new FSS key pair]' \
79     '--force[Force recreation of FSS keys]' \
80     '--interval=[Time interval for changing the FSS sealing key]:time interval' \
81     '--verify[Verify journal file consistency]' \
82     '--verify-key=[Specify FSS verification key]:FSS key' \
83     '*::default: _journal_none'