Skip to main content

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

Hi Bernd,

Looks great, and quite interesting!

Imo I think long options should always use double dashes (--), unlike what java and mvn do...


One question though, what is the end goal of this interface? Is it only to launch Trace Compass with a given context (trace, time range, etc)? Or to eventually *control* a running instance of Trace Compass?

If it's only the former, then fine, "./tracecompass --cli etc." should cover everything.

However if it's the latter, then it's a totally different beast. That would imply a separate daemon running, which would be completely separate program. That program wouldn't even have to be in Java (although having it in Java too could make distribution easier). You would have much more liberty in how that is implemented, since there would be no Eclipse options in the way. It could even be built and/or packaged separately.

One example of a similar program I know is "nmcli", to control Network Manager from the command line. The "main" program is the icon in the toolbar, but the nmcli tool offers a different way of doing the same actions that are accessible from the UI.


But then again, it depends on what you what this interface to be able to do.

Cheers,
Alex


On 2016-02-04 11:17 AM, Bernd Hufmann wrote:
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







_______________________________________________
tracecompass-dev mailing list
tracecompass-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tracecompass-dev



Back to the top