termux-app

Форк
0
75 строк · 4.4 Кб
1
package com.termux.shared.shell.command;
2

3
import com.termux.shared.errors.Errno;
4
import com.termux.shared.shell.command.result.ResultConfig;
5

6
import java.util.Formatter;
7
import java.util.IllegalFormatException;
8

9
public class ShellCommandConstants {
10

11
    /**
12
     * Class to send back results of commands to their callers like plugin or 3rd party apps.
13
     */
14
    public 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 to
22
         * {@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. */
25
        public 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 to
27
         * {@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. */
31
        public 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 be
33
         * 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. */
40
        public 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. */
53
        public 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. */
63
        public static final String RESULT_FILE_ERR_PREFIX = "err";
64
        /** The prefix for the errmsg result file. */
65
        public static final String RESULT_FILE_ERRMSG_PREFIX = "errmsg";
66
        /** The prefix for the stdout result file. */
67
        public static final String RESULT_FILE_STDOUT_PREFIX = "stdout";
68
        /** The prefix for the stderr result file. */
69
        public static final String RESULT_FILE_STDERR_PREFIX = "stderr";
70
        /** The prefix for the exitCode result file. */
71
        public static final String RESULT_FILE_EXIT_CODE_PREFIX = "exit_code";
72

73
    }
74

75
}
76

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.