fortify / fcli

fcli is a command-line utility for interacting with various Fortify products
https://fortify.github.io/fcli/
Other
31 stars 17 forks source link

Dynamic command headers #328

Open rsenden opened 1 year ago

rsenden commented 1 year ago

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:

Commands:
  session         Manage SSC sessions (active: 2)
  activity-feed ...
  ...

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:

fcli.ssc.session.usage.header.suffix = (start here)
fcli.ssc.session.usage.header = Manage SSC sessions ${fcli.ssc.session.usage.header.suffix}

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: