Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an option to use stdout/stdin instead of files #15

Open
Morozzzko opened this issue Mar 15, 2020 · 4 comments
Open

Provide an option to use stdout/stdin instead of files #15

Morozzzko opened this issue Mar 15, 2020 · 4 comments
Labels
backlog Queued in backlog pr welcome We rely on a community contribution to improve this.

Comments

@Morozzzko
Copy link

Is your feature request related to a problem? Please describe

I'm building a simple integration for BPMN and Jekyll. Here's my use-case:

  1. I write an article, which uses BPMN diagrams
  2. I design said diagrams and export them as .bpmn files
  3. I convert the .bpmn files to .svg and .png and embed them in the article

Since I'm using it from Ruby, I've decided to just call the CLI program and use its output.

However, there's something complicated: I have to perform it in-memory. See how I tackled it:

  1. I create a tempfile and write the original content. It's an XML file with the BPMN diagram
  2. I create another tempfile – I'll use it as a buffer for the CLI
  3. I call bpmn-to-image ${tmpFileWithSource.path}:${tmpFileWithSVG.path}.svg
  4. I read from tmpFileWithSVG

CLI docs haven't given me any other ideas how to proceed

Describe the solution you'd like

I would love to have an option to use standard OS streams for input an output.

Let's see how it might look like:

echo "...some_xml_with_bpmn" | bpmn-to-image --source=stdin --target=stdout

There's a lot of ways to design it, anything will work as long as it lets me use standard stream

Describe alternatives you've considered

Thought about writing a different javascript utility, which doesn't really work as a CLI, but it won't be that good.

Additional context

Since I'm the one who needs this feature, I can code it if you give me a green light

Please keep in mind that right now the CLI looks like it can generate multiple files in a single run. It will be tricky to keep this behavior using the new interface.
Alternatively, we could keep those two interfaces, but make them mutually exclusive.

@Morozzzko Morozzzko added the enhancement New feature or request label Mar 15, 2020
@nikku
Copy link
Member

nikku commented Mar 15, 2020

Happy to take a PR that implements this feature.

@nikku nikku added pr welcome We rely on a community contribution to improve this. and removed enhancement New feature or request labels Mar 15, 2020
@pinussilvestrus pinussilvestrus added the backlog Queued in backlog label Mar 15, 2020 — with bpmn-io-tasks
@Morozzzko
Copy link
Author

I think I'll try and introduce a breaking change, then.

I'm thinking it would be reasonable to pick this approach:

I want to change the CLI interface to something like this
bpmn-to-image --destination=current_destination_list_format.png,some_other_value.svg source_file

It introduces a breaking change, but empowers us to do lots of things:

  1. It decouples input and output param, so we can extend and evolve each of them separately. The users will need to adjust a little, but it's not going to be too painful
  2. Conventionally, we can omit the last argument (source_file) and pipe something to STDIN. It's pretty idiomatic in unix. Virtually, <file.bpmn | bpmn-to-image --destination=foo.png and bpmn-to-image --destination=foo.png file.bpmn are going to be identical. It's good
  3. We can say that if --destination is not set, it will print to STDOUT. Pretty neat, I think

What do you think about it? I think a breaking change is a bold move, but it's still a zero-version, so why not

@nikku
Copy link
Member

nikku commented Mar 16, 2020

The goal of the current CLI is to be able to batch migrate several diagrams.

Is that something that can be kept as a feature with your proposal?

@Morozzzko
Copy link
Author

I think we can keep the behavior by using subcommands for different scenarios

$ bpmn-to-image convert --destination=foo.png,svg,somethingelse.pdf single_source.bpmn
$ bpmn-to-image batch diagram.bpmn:svg vertical.bpmn:svg,something.pdf,somethingelse.png

It's going to be a bit tricky to implement using meow, but I think I can manage it.

Alternatively, we could provide different cli commands for each use-case, how they do with a lot linux utilities. Not sure about that, though.

What do you think about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog pr welcome We rely on a community contribution to improve this.
Projects
None yet
Development

No branches or pull requests

3 participants