In some cases, it might be useful to have dynamic command headers shown in the usage help information. For example, if there are any active SSC sessions, the fcli ssc -h command could display the number of open/active sessions in the description of the session sub-command. For example, the output of fcli ssc -h could show the following:
This could be implemented by having each module provide IFortifyCLIInitializer implementations to set system properties that are then referenced in the resource bundles. The resource bundles should provide a default value for each of these system properties, to allow for correct manpage generation.
In the example above, the resource bundle would contain the following entries:
A corresponding IFortifyCLIInitializer implementation would then check whether there are any active SSC sessions, and set the fcli.ssc.session.usage.header.suffix system property to (active: <number>) if there are any active sessions, thereby overriding the default (start here) value defined in the resource bundle.
Some notes:
Any words in the system property set by the IFortifyCLIInitializer implementation should be internationalized as well. For example, the word active would need to be internationalized, such that for example actief is used instead if Dutch language is configured.
In the example above, active is probably not a good word as this may be misleading for users, as this would likely include token-based sessions, whereas fcli cannot determine whether the tokens used by token-based sessions have expired (i.e., no longer active)
IFortifyCLIInitializer implementations run on every fcli start-up, so checking for active sessions for every product module may have a small performance impact. Ideally, the initializers should check which command the user is trying to invoke. In the example above, SSC session data only needs to be loaded if fcli ssc or fcli ssc session commands are being invoked. Note that the system property should always be set when those commands are being invoked, independent of whether the user explicitly specified the -h/--help options, as picocli may also display help information in case of missing or invalid options.
In some cases, it might be useful to have dynamic command headers shown in the usage help information. For example, if there are any active SSC sessions, the
fcli ssc -h
command could display the number of open/active sessions in the description of thesession
sub-command. For example, the output offcli ssc -h
could show the following:This could be implemented by having each module provide
IFortifyCLIInitializer
implementations to set system properties that are then referenced in the resource bundles. The resource bundles should provide a default value for each of these system properties, to allow for correct manpage generation.In the example above, the resource bundle would contain the following entries:
A corresponding
IFortifyCLIInitializer
implementation would then check whether there are any active SSC sessions, and set thefcli.ssc.session.usage.header.suffix
system property to(active: <number>)
if there are any active sessions, thereby overriding the default(start here)
value defined in the resource bundle.Some notes:
IFortifyCLIInitializer
implementation should be internationalized as well. For example, the wordactive
would need to be internationalized, such that for exampleactief
is used instead if Dutch language is configured.active
is probably not a good word as this may be misleading for users, as this would likely include token-based sessions, whereas fcli cannot determine whether the tokens used by token-based sessions have expired (i.e., no longer active)IFortifyCLIInitializer
implementations run on every fcli start-up, so checking for active sessions for every product module may have a small performance impact. Ideally, the initializers should check which command the user is trying to invoke. In the example above, SSC session data only needs to be loaded iffcli ssc
orfcli ssc session
commands are being invoked. Note that the system property should always be set when those commands are being invoked, independent of whether the user explicitly specified the-h
/--help
options, as picocli may also display help information in case of missing or invalid options.