epm-tool 2.35 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2022, 2023  Etersoft
# Copyright (C) 2022, 2023  Vitaly Lipatov <lav@etersoft.ru>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

20 21
epm_tool_help()
{
22
    message "Tools embedded in epm:"
23
    get_help HELPCMD $SHAREDIR/epm-tool
24

25
    message '
26 27 28
  Examples:
    epm tool eget -U http://ya.ru
    epm tool estrlist union a b a c
29
    epm tool erc archive.zip
30
'
31
}
32 33 34 35 36 37 38 39

epm_tool()
{
    local WHAT="$1"
    shift

    case "$WHAT" in
        "")
40
            fatal "Use epm tool --help to get help."
41 42
            ;;
        "-h"|"--help"|"help")
43
            epm_tool_help
44
            ;;
45
        "eget")                      # HELPCMD: downloading tool (simular to wget or curl)
46
            showcmd eget "$@"
47 48
            eget "$@"
            ;;
49 50 51 52 53 54 55 56
        "erc")                       # HELPCMD: universal archive manager
            showcmd erc "$@"
            erc "$@"
            ;;
        "ercat")                     # HELPCMD: universal file uncompressor
            showcmd ercat "$@"
            ercat "$@"
            ;;
57
        "estrlist")                  # HELPCMD: string operations
58
            showcmd estrlist "$@"
59 60
            estrlist "$@"
            ;;
61
        "json")                      # HELPCMD: json operations
62
            showcmd json "$@"
63
            $CMDSHELL $SHAREDIR/tools_json "$@"
64
            ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
65 66 67 68
        "yaml")                      # HELPCMD: parse yaml operations
            showcmd yaml "$@"
            $CMDSHELL $SHAREDIR/tools_yaml "$@"
            ;;
69 70
        "which")                    # HELPCMD: which like command (no output to stderr, can works without which package)
            print_command_path "$@"
71
            ;;
72
        *)
73
            fatal 'Unknown command $ epm tool $WHAT. Use epm print help for get help.'
74 75 76
            ;;
    esac
}