OSDN Git Service

Fixed the wrong implementation of show errormessage.
[portsreinstall/current.git] / lib / libcommand.sh
1 #!/bin/sh -e
2 # ==============================================================================
3 # portsreinstall library script
4 # - Interface of libraries for operations of commands as well as check of command line arguments -
5 # Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
6 # This software is distributed under the 2-Clause BSD License.
7 # ==============================================================================
8
9 # ============= Variables =============
10 COMMAND_MODE=do
11 COMMAND_SHIFT=0
12 COMMAND_OPERATION=
13 COMMAND_SAVE_DIR=
14 COMMAND_LOAD_FILE=
15 COMMAND_SHOW_SUBJECT=
16 COMMAND_DO_MODE=all
17 COMMAND_RESTART=
18 COMMAND_SHOW_OPTIONS=
19 COMMAND_SHOW_DEPTAG=
20 COMMAND_SHOW_LEVEL=
21
22 # ============= Check the necessity of opening notice =============
23 command_all_chk_need_opening_notice ()
24 {
25         :
26 }
27
28 # ============= Check the number of following command line arguments (in case glob arguments are needed) =============
29 _command_parse_args__chk_glob_args ()
30 {
31         local nargs
32         nargs=1
33         [ $nargs -gt 0 ] && return
34         message_echo "ERROR: No port glob is specified." >&2
35         exit 1
36 }
37
38 # ============= Check the number of following command line arguments (in case without arguments) =============
39 _command_parse_args__chk_no_arg ()
40 {
41         local nargs term_redundant_argument
42         nargs=$1
43         [ $nargs -eq 0 ] && return
44         term_redundant_argument='A redundant argument is'
45         [ $nargs -gt 1 ] && term_redundant_argument='Redundant arguments are'
46         message_echo "ERROR: $term_redundant_argument specified." >&2
47         exit 1
48 }
49
50 # ============= Execute command operations before getting the temporary database ready =============
51 command_all_exec_before_db_creation ()
52 {
53 }
54
55 # ============= Check and parse command line arguments =============
56 command_all_parse_args ()
57 {
58 }
59
60 # ============= Notify that option settings are reset =============
61 command_exec_without_pkgtools__notify_reset_options ()
62 {
63         message_echo "NOTE: Option settings are ignored (because of no effect) and reset."
64 }
65
66 # ============= Execute command operations which do not need package tools =============
67 command_all_exec_without_pkgtools ()
68 {
69 }
70
71
72 # ============= Notify that option settings are ignored because of no effect =============
73 _command_exec_irrespective_of_saved_options__notify_ignored_options ()
74 {
75         [ $opt_no_opening_message = yes ] && return
76         message_echo "NOTE: Option settings are ignored because they have no effect on this command."
77 }
78
79 # ============= Execute command operations which are irrespective of option settings =============
80 command_all_exec_irrespective_of_saved_options ()
81 {
82 }
83
84 # ============= Execute command operations which should be done without upgrade of tools =============
85 command_all_exec_before_tools_upgrade ()
86 {
87 }
88
89 # ============= Execute command operations which must be done before the database construction =============
90 command_all_exec_before_build_database ()
91 {
92 }
93
94 # ============= Execute command operations of database construction =============
95 command_all_exec_build_database ()
96 {
97 }
98
99 # ============= Execute command operations which must be done before the main process =============
100 command_all_exec_before_main ()
101 {
102 }
103
104 # ============= Execute command operations as the main process =============
105 command_all_exec_main ()
106 {
107 }