1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "output-mode.h"
4 #include "string-table.h"
5
output_mode_to_json_format_flags(OutputMode m)6 JsonFormatFlags output_mode_to_json_format_flags(OutputMode m) {
7
8 switch (m) {
9
10 case OUTPUT_JSON_SSE:
11 return JSON_FORMAT_SSE;
12
13 case OUTPUT_JSON_SEQ:
14 return JSON_FORMAT_SEQ;
15
16 case OUTPUT_JSON_PRETTY:
17 return JSON_FORMAT_PRETTY;
18
19 default:
20 return JSON_FORMAT_NEWLINE;
21 }
22 }
23
24 static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
25 [OUTPUT_SHORT] = "short",
26 [OUTPUT_SHORT_FULL] = "short-full",
27 [OUTPUT_SHORT_ISO] = "short-iso",
28 [OUTPUT_SHORT_ISO_PRECISE] = "short-iso-precise",
29 [OUTPUT_SHORT_PRECISE] = "short-precise",
30 [OUTPUT_SHORT_MONOTONIC] = "short-monotonic",
31 [OUTPUT_SHORT_UNIX] = "short-unix",
32 [OUTPUT_VERBOSE] = "verbose",
33 [OUTPUT_EXPORT] = "export",
34 [OUTPUT_JSON] = "json",
35 [OUTPUT_JSON_PRETTY] = "json-pretty",
36 [OUTPUT_JSON_SSE] = "json-sse",
37 [OUTPUT_JSON_SEQ] = "json-seq",
38 [OUTPUT_CAT] = "cat",
39 [OUTPUT_WITH_UNIT] = "with-unit",
40 };
41
42 DEFINE_STRING_TABLE_LOOKUP(output_mode, OutputMode);
43