Skip to content

Usage e.g. for Commands #1

Open

Description

@frauzufall

Could this be used to pass options to a command / plugin?

E.g.

commandService.run(Threshold.class, true, new ThresholdOptions().setThreshold(0.5));
ioService.open("table.xml", new TableOptions().readLine(true));

For the CommandService, this could be executed by adding

Future<CommandModule> run(String className, boolean process,
        Options options) {
   return run(className, process, options.map());
}

(though options.map() does not exist in the current implementation of the Options interface)

.. We could actually get rid of the process parameter as well this way (in a new iteration of the command service) - with something like:

commandService.run("mycommand", new CommandOptions().runPrePostProcessing(true));

.. or is this stupid because you don't know if the options match the command which is chosen by the CommandService?

@ctrueden @imagejan

Activity

  1. ctrueden commented on Apr 20, 2020

    @ctrueden
    Member

    @frauzufall Why not just make the FooOptions object in question an @Parameter of the FooCommand, like anything else? This would be a really nice way of doing things, benefiting from the builder pattern and avoiding frequent breaking command parameter signature changes.

  2. imagejan commented on Apr 21, 2020

    @imagejan
    Member

    @ctrueden wrote:

    This would be a really nice way of doing things, benefiting from the builder pattern

    I agree this would be nice. One downside would be however that the usage from command line would be difficult.

    ImageJ --run MyCommand 'stringParam="foo",intParam=42'
    

    If MyCommand is changed to take a single MyCommandOptions parameter, we would have to think of a way of parsing the option string to create that MyCommandOptions from the given key-value pairs, no?

  3. frauzufall commented on Apr 21, 2020

    @frauzufall
    MemberAuthor

    Wouldn't we also run into issues with the macro recorder?

    I would prefer

    commandService.run("mycommand", options);
    

    much more than

    commandService.run("mycommand", true, "options", options);
    

    .. but maybe that's just me. There are other places where I would enjoy having a possibility to pass options, like this:

    ioService.open("table.xml", new TableOptions().readRowHeader(true));
    
  4. frauzufall commented on Apr 24, 2020

    @frauzufall
    MemberAuthor

    PR #3 would allow us to do this without changing the CommandService. It would not help with the IOService, but that's maybe a different discussion.

  5. imagejan commented on Apr 24, 2020

    @imagejan
    Member

    I think we can adapt the API of IOService (or in particular TableIOService) as required to allow this usage, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions