termux-app
75 строк · 4.4 Кб
1package com.termux.shared.shell.command;2
3import com.termux.shared.errors.Errno;4import com.termux.shared.shell.command.result.ResultConfig;5
6import java.util.Formatter;7import java.util.IllegalFormatException;8
9public class ShellCommandConstants {10
11/**12* Class to send back results of commands to their callers like plugin or 3rd party apps.
13*/
14public static final class RESULT_SENDER {15
16/*17* The default `Formatter` format strings to use for `ResultConfig#resultFileBasename`
18* if `ResultConfig#resultSingleFile` is `true`.
19*/
20
21/** The {@link Formatter} format string for success if only `stdout` needs to be written to22* {@link ResultConfig#resultFileBasename} where `stdout` maps to `%1$s`.
23* This is used when `err` equals {@link Errno#ERRNO_SUCCESS} (-1) and `stderr` is empty
24* and `exit_code` equals `0` and {@link ResultConfig#resultFileOutputFormat} is not passed. */
25public static final String FORMAT_SUCCESS_STDOUT = "%1$s%n";26/** The {@link Formatter} format string for success if `stdout` and `exit_code` need to be written to27* {@link ResultConfig#resultFileBasename} where `stdout` maps to `%1$s` and `exit_code` to `%2$s`.
28* This is used when `err` equals {@link Errno#ERRNO_SUCCESS} (-1) and `stderr` is empty
29* and `exit_code` does not equal `0` and {@link ResultConfig#resultFileOutputFormat} is not passed.
30* The exit code will be placed in a markdown inline code. */
31public static final String FORMAT_SUCCESS_STDOUT__EXIT_CODE = "%1$s%n%n%n%nexit_code=%2$s%n";32/** The {@link Formatter} format string for success if `stdout`, `stderr` and `exit_code` need to be33* written to {@link ResultConfig#resultFileBasename} where `stdout` maps to `%1$s`, `stderr`
34* maps to `%2$s` and `exit_code` to `%3$s`.
35* This is used when `err` equals {@link Errno#ERRNO_SUCCESS} (-1) and `stderr` is not empty
36* and {@link ResultConfig#resultFileOutputFormat} is not passed.
37* The stdout and stderr will be placed in a markdown code block. The exit code will be placed
38* in a markdown inline code. The surrounding backticks will be 3 more than the consecutive
39* backticks in any parameter itself for code blocks. */
40public static final String FORMAT_SUCCESS_STDOUT__STDERR__EXIT_CODE = "stdout=%n%1$s%n%n%n%nstderr=%n%2$s%n%n%n%nexit_code=%3$s%n";41/** The {@link Formatter} format string for failure if `err`, `errmsg`(`error`), `stdout`,42* `stderr` and `exit_code` need to be written to {@link ResultConfig#resultFileBasename} where
43* `err` maps to `%1$s`, `errmsg` maps to `%2$s`, `stdout` maps
44* to `%3$s`, `stderr` to `%4$s` and `exit_code` maps to `%5$s`.
45* Do not define an argument greater than `5`, like `%6$s` if you change this value since it will
46* raise {@link IllegalFormatException}.
47* This is used when `err` does not equal {@link Errno#ERRNO_SUCCESS} (-1) and
48* {@link ResultConfig#resultFileErrorFormat} is not passed.
49* The errmsg, stdout and stderr will be placed in a markdown code block. The err and exit code
50* will be placed in a markdown inline code. The surrounding backticks will be 3 more than
51* the consecutive backticks in any parameter itself for code blocks. The stdout, stderr
52* and exit code may be empty without any surrounding backticks if not set. */
53public static final String FORMAT_FAILED_ERR__ERRMSG__STDOUT__STDERR__EXIT_CODE = "err=%1$s%n%n%n%nerrmsg=%n%2$s%n%n%n%nstdout=%n%3$s%n%n%n%nstderr=%n%4$s%n%n%n%nexit_code=%5$s%n";54
55
56
57/*58* The default prefixes to use for result files under `ResultConfig#resultDirectoryPath`
59* if `ResultConfig#resultSingleFile` is `false`.
60*/
61
62/** The prefix for the err result file. */63public static final String RESULT_FILE_ERR_PREFIX = "err";64/** The prefix for the errmsg result file. */65public static final String RESULT_FILE_ERRMSG_PREFIX = "errmsg";66/** The prefix for the stdout result file. */67public static final String RESULT_FILE_STDOUT_PREFIX = "stdout";68/** The prefix for the stderr result file. */69public static final String RESULT_FILE_STDERR_PREFIX = "stderr";70/** The prefix for the exitCode result file. */71public static final String RESULT_FILE_EXIT_CODE_PREFIX = "exit_code";72
73}74
75}
76