Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tracecompass-dev] Trace Compass command-line interface

Hello

Trace Compass team would like to add some more command-line options to the Trace Compass RCP to allow users to open traces, run analyses, create experiments, seek to specific time ranges and more from the command-line.

For that, I did an investigation about Java libraries for command line parsing that could be used for Trace Compass. I found multiple libraries on the web that are available for that. I had then a closer look at Apache Commons CLI [1] because it is available in Eclipse orbit and it would be straight forward to add this dependency to Trace Compass. Right now version 1.2 is part of the orbit current release.

It supports different type of command-line options (taken from [1])
  • POSIX like options (ie. tar -zxvf foo.tar.gz)
  • GNU like long options (ie. du --human-readable --max-depth=1)
  • Java like properties (ie. java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo)
  • Short options with value attached (ie. gcc -O2 foo.c)
  • long options with single hyphen (ie. ant -projecthelp)
What it doesn't seem to support is a git-like command-line interface with a main command (e.g. git) and sub-commands (e.g. rebase) where the main and each sub-command could have set of options themselves. If we'd like to got that route, then some more investigation is need for that. Worst case scenario, would be that we need to implement our own custom CLI parser.

I experimented a bit with the API and created a prototype for that (see patch [2]). It was straight forward to use it. I added some example options and also re-implemented the existing "--open path-to-trace" command-line.
If you'd like to try it out use for example: "./tracecompass --cli --help", "./tracecompass --cli --open path-to-trace" or "./tracecompass --cli --open path-to-trace --zoom "11:24:49.550 094 360,11:24:49.649 408 317" ". Note --cli is used to easily filter out any Eclipse related options passed on.

What needs to be done next:
  • Propose and agree on command-line syntax. For that it would be good to look at good examples of tools with command-line interfaces.
  • Choose the right java command-line parser library or/and implement our own (if needed).
  • Update the current command-line (to the new library)
  • Incrementally implement the handlers for different options

One note, the main use case of the command-line should be very straight-forward for the user.

Comments are welcome.

Best Regards
Bernd


[1] https://commons.apache.org/proper/commons-cli/index.html
[2] https://git.eclipse.org/r/#/c/65906





Back to the top