1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
package Torello.Java.Build;

import Torello.Java.ReadOnly.ReadOnlyList;
import Apache.CLI.Option;

import java.util.Objects;

import static Torello.Java.C.BYELLOW;
import static Torello.Java.C.BRED;
import static Torello.Java.C.RESET;
import static Torello.Java.C.BCYAN;


// ************************************************************************************************
// ************************************************************************************************
// THIS RECORD IS EPHEMERAL.  IT IS INSTANTIATED INSIDE CLASS CLI'S CONSTRUCTOR.
// ************************************************************************************************
// ************************************************************************************************
// 
// No instances are transmitted out of the CLI-Constructor.
//
// It is created as a separate Record-Class in a simple, and vainglorious manner of attempting
// to make this plate of Spaghetti-Code somewhat more clear.  Every little bit helps.

/**
 * This class is a Giant-Replacement for the original {@link Apache.CLI} class
 * {@link FormatHelper}
 * 
 * <!-- Contains the black-banner declaring this is a CLI-group internally used class -->
 * <EMBED CLASS='external-html' DATA-FILE-ID=CLI_INTERNAL_USE>
 * 
 * <BR /><BR />
 * This class prints the Help-Menu to the Command-Line / Terminal.  It is an extremely simple
 * class, that just contains four private String-Fields, and two private Integers.  It has tons
 * of documentation, though, mostly to explain how the Command-Line Main-Menu is actually
 * constructed.
 * 
 * <BR /><BR />
 * The Four String-Fields contain:
 *  1) A String for all Menu-Tet about the "Primary Build Steps"
 *  2) A String for all Menu-Text related to "Composite-Build Stages" of "Complete-Builds"
 *  3) A String for all Menu-Text related to "Composite-Build Steps" of "Partial-Builds"
 *  4) The Menu-Text (as a java.lang.String) for all "Auxiliary Options"
 * 
 * HINT: The CLI Main-Menu, itself, (as Apache.CLI 'Option' Object-Instances) is built inside
 *       Package-Private top-level dispatch class "Generate".
 * 
 * This class does nothing but save the Menu-String's inside some private fields here.
 * The String's are generated there so that the Main-Menu Text (as a String that can be printed
 * to the UNIX/DOS Terminal) IS IDENTICAL to the Main-Menu Text that is saved inside of the
 * Apache.CLI "Option" instances / Object-References.
 * 
 * NOTE: December 2024, this class now implements the interface "MainMenuPrinter"
 *       This allows the Primary Build-CLI to share the class "ProcessNickNameArgs" with the
 *       secondary CLI-Programs "TestingCLI" (and, hopefully / eventually, DataFileBuild CLI)
 * 
 * "MainMenuPrinter" is a simple, one line, Functional-Interface.
 */
class PrintHelpRecord implements MainMenuPrinter
{
    // ********************************************************************************************
    // ********************************************************************************************
    // Main-Menu "Partial-Menu" stuff - Each of the following fields comprise 1/3 of the Main-Menu
    // ********************************************************************************************
    // ********************************************************************************************


    // These String's have very long names because "User-Interacee" Code is always difficult to
    // explain.  If you run a program that accepts User-Input, it's usually easy to understand
    // what is going.  But unfortunately, reading source code comments is not the same experience
    // as running the program - so I leave these long variable-names in place.
    // 
    // To Reiterate:
    // 
    // These String's are constructed there because it helps "Keep Together" both the
    // Option-Descriptions **AND** The Option Object/Reference instances right next to each-other.
    // Class "Generate" has the actual text String-Literal's that build the Menu's.  By keeping all
    // of the actual String-Literal's for BOTH the Apache-CLI Option Object-References, and the
    // String-Literal's for the CLI-Printed Menu in the exact same class (Class "Generate", and
    // its helpers), I am able to:
    // 
    //      1) If anything changes with the Main-Menu, it is easy to understand what has changed.
    // 
    //      2) The Menu-Text messages, themselves, are more consistent between the Printed-Menu and
    //         the instance/reference/variable declarations.  The exact same String is used for
    //         both!!
    // 
    //      3) Ensuring nothing is left out, and none of the Primary, Composite or Auxillary
    //         options have been "elided" (to use a popular term from Oracle these days
    //         vis-a-vis the new '_' operator).  Essentially, all of the options for which there
    //         are references, there will also be Options printed at the Command-Line Terminal to
    //         Main-Menu / MAN-Page thing.
    // 
    // PLEASE REVIEW THE CONTENTS OF CLASS "Generate" AND ITS HELPERS TO SEE, FIRST-HAND, HOW THESE
    // STRING-FIELDS ARE POPULATED.

    // This keeps the 8 **PRIMARY** Build-Stages / Steps for the Print-Menu as a single String.
    // This String is constructed in the class "Generate". 
    // 
    // This String contains the "Primary Build Stage / Step Options" as a MAN-Page String.

    private final String mainMenu_PrimaryOptions_Str;


    // This String is used to Print "Composite Build Steps" for a "Complete Build".
    // 
    // These are the options which began with the letters "-cb" and are followed by a digit.
    // For example "-cb1" is the first "Composite-Step, Complete-Build" Menu-Option.
    // This string is built & constructed  inside the class "Generate" - for the same reason as
    // depicted with the previous private field.

    private final String mainMenu_CompositeSteps_CompleteBuildOpts_Str;


    // This String is used to print "Composite-Build Steps" for a "Partial-Build"
    // 
    // Each option in this Menu-String begins with the letters "-pb" and is followed by a digit.
    // "-pb1" is the first Partial-Build Option offered.

    private final String mainMenu_CompositeSteps_PartialBuildOpts_Str;


    // This is the list of "Non-Main-Menu Options".
    // 
    // I'm going to block copy the original definition of this field.
    // 
    // BYELLOW + "\n\n\tAdditional Side Options:" + RESET +
    //      "\n\t\t-JCP,--putJarInCP             " + GenerateOptions.descriptionNQB +
    //      "\n\t\t-NQB,--noQuickBuild           " + GenerateOptions.descriptionJCP +
    //      "\n\t\t-SRG,--skipRemoveGCSFiles     " + GenerateOptions.descriptionSRG +
    //      "\n\t\t-TXD,--toggleDefaultXdiags    " + GenerateOptions.descriptionTXD +
    //      "\n\t\t-TXL,--toggleDefaultXlint     " + GenerateOptions.descriptionTXL +
    //      "\n\t\t-IEDP,--includeEarlyDev       " + GenerateOptions.descriptionIEDP +

    private final String nonMainMenu_AuxiliaryOptions_Str;


    // A count on the number of "Complete Build" steps, and "Partial Build" Steps that are being
    // offered / provided by the User's Config Cloud-Sync instances.
    // 
    // The "cbCount" is used soley in the method "messageSRG()"
    // The "pbCount" is only used in the method "messageNQB()"

    private final int cbCount, pbCount;


    // ********************************************************************************************
    // ********************************************************************************************
    // Constructor Fields
    // ********************************************************************************************
    // ********************************************************************************************


    PrintHelpRecord(
            final int       cbCount,
            final int       pbCount,
            final String    mainMenu_PrimaryOptions_Str,
            final String    mainMenu_CompositeSteps_CompleteBuildOpts_Str,
            final String    mainMenu_CompositeSteps_PartialBuildOpts_Str,
            final String    nonMainMenu_AuxiliaryOptions_Str
        )
    {
        Objects.requireNonNull(mainMenu_PrimaryOptions_Str);
        Objects.requireNonNull(mainMenu_CompositeSteps_CompleteBuildOpts_Str);
        Objects.requireNonNull(mainMenu_CompositeSteps_PartialBuildOpts_Str);
        Objects.requireNonNull(nonMainMenu_AuxiliaryOptions_Str);

        this.cbCount                        = cbCount;
        this.pbCount                        = pbCount;
        this.mainMenu_PrimaryOptions_Str    = mainMenu_PrimaryOptions_Str;

        this.mainMenu_CompositeSteps_CompleteBuildOpts_Str =
            mainMenu_CompositeSteps_CompleteBuildOpts_Str;

        this.mainMenu_CompositeSteps_PartialBuildOpts_Str =
            mainMenu_CompositeSteps_PartialBuildOpts_Str;

        this.nonMainMenu_AuxiliaryOptions_Str = nonMainMenu_AuxiliaryOptions_Str;
    }            


    // ********************************************************************************************
    // ********************************************************************************************
    // This class exported (Package-Private) API => "This is the only thing this class really does"
    // ********************************************************************************************
    // ********************************************************************************************


    public /* Implements the Functional-Interface, must be public! */
    void print_MainMenu_Options()
    {
        System.out.println(
            this.mainMenu_PrimaryOptions_Str +
            this.mainMenu_CompositeSteps_CompleteBuildOpts_Str +
            this.mainMenu_CompositeSteps_PartialBuildOpts_Str +

            BYELLOW + "\n\n\tLinks-Checker:" + RESET +
            "\n\t\t-LC  -> STEPS 2 and 3, WITH-LINKS-CHECK" +

            this.nonMainMenu_AuxiliaryOptions_Str +
            "\n"
        );
    }

    String messageNQB()
    {
        StringBuilder sb = new StringBuilder();

        for (int i=1; i <= this.pbCount; i++)
            sb.append(" -pb" + i + ((i < this.pbCount) ? " |" : ""));

        return 
            "The Command-Switch " + BRED + "--noQuickBuild" + RESET + " (-NQB) may " +
            "only be applied to the Partial-Build Menu-Options " +
            BRED + "--partialX" + RESET + " (" + sb.toString() + ") or to the " +
            BRED + "--javac" + RESET + " (-1) Option.";
    }

    String messageSRG()
    {
        StringBuilder sb = new StringBuilder();

        for (int i=1; i <= this.cbCount; i++)
            sb.append(" -cb" + i + ((i < this.cbCount) ? " |" : ""));

        return
            "The Command-Switch " + BRED + "--skipRemoveGCSFiles" + RESET + " (-SRG) may " +
            "only be applied to the Complete-Build Menu-Options  " +
            BRED + "--completeX" + RESET + " (" + sb.toString() + ')';
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Some Simple java.lang.Object Stuff
    // ********************************************************************************************
    // ********************************************************************************************


    // If I ever switch to JDK-21 / Records, these are created automatically by the compiler, and
    // I wouldn't need to type "equals(...)" or "toString()"
    // 
    // NOTE: Here are the fields inside this class, cut-and-copy-pasted for your benefit!
    // 
    // private final String mainMenu_PrimaryOptions_Str;
    // private final String mainMenu_CompositeSteps_CompleteBuildOpts_Str;
    // private final String mainMenu_CompositeSteps_PartialBuildOpts_Str;
    // private final String nonMainMenu_ExtraOptions_Str;
    // private final int cbCount, pbCount;

    public String toString()
    {
        return 
            BCYAN + "this.mainMenu_PrimaryOptions_Str:\n\n" + RESET +
            this.mainMenu_PrimaryOptions_Str + "\n\n" +

            BCYAN + "this.mainMenu_CompositeSteps_CompleteBuildOpts_Str:\n\n" + RESET +
            this.mainMenu_CompositeSteps_CompleteBuildOpts_Str + "\n\n" +

            BCYAN + "this.mainMenu_CompositeSteps_PartialBuildOpts_Str:\n\n" + RESET +
            this.mainMenu_CompositeSteps_PartialBuildOpts_Str + "\n\n" +

            BCYAN + "this.nonMainMenu_AuxiliaryOptions_Str:\n\n" + RESET +
            this.nonMainMenu_AuxiliaryOptions_Str + "\n\n" +

            BCYAN + "this.cbCount: " + RESET +
            this.cbCount + "\n" +

            BCYAN + "this.pbCount: " + RESET +
            this.pbCount + "\n";
    }

    // I don't know why I types this, I'll never use it.  It helps calm my nerves since the fields
    // inside this class have such bizarre and long names, when all they are are String's!

    public boolean equals(Object o)
    {
        if (! (o instanceof PrintHelpRecord)) return false;

        final PrintHelpRecord other = (PrintHelpRecord) o;

        return
                (this.cbCount == other.cbCount)
            &&  (this.pbCount == other.pbCount)

            &&  Objects.equals
                (this.mainMenu_PrimaryOptions_Str, other.mainMenu_PrimaryOptions_Str)

            &&  Objects.equals(
                    this.mainMenu_CompositeSteps_CompleteBuildOpts_Str,
                    other.mainMenu_CompositeSteps_CompleteBuildOpts_Str
                )

            &&  Objects.equals(
                    this.mainMenu_CompositeSteps_PartialBuildOpts_Str,
                    other.mainMenu_CompositeSteps_PartialBuildOpts_Str
                )

            &&  Objects.equals
                (this.nonMainMenu_AuxiliaryOptions_Str, other.nonMainMenu_AuxiliaryOptions_Str);
    }

    public int hashCode()
    {
        return
            this.cbCount + this.pbCount +
            this.mainMenu_CompositeSteps_CompleteBuildOpts_Str.hashCode() +
            this.mainMenu_CompositeSteps_PartialBuildOpts_Str.hashCode();
    }
}