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

Fixes error on | character in CLI #1634

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

rishabhshuklax
Copy link
Member

@rishabhshuklax rishabhshuklax commented Feb 21, 2020

Fixes #1033
Fixes #1040

This PR fixes error on | character in CLI inputs

The supported syntax after this PR would be

./index.js -s "contrast{contrast:55},blur{blur:2.4}" -i examples/images/test.png

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with npm run test-all
  • code is in uniquely-named feature branch and has no merge conflicts
  • PR is descriptively titled
  • ask @publiclab/is-reviewers for help, in a comment below
  • Insert-step functionality is working correct as expected.

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Please make sure to get at least two reviews before asking for merging the PR as that would make the PR more reliable on our part
Thanks!

@rishabhshuklax
Copy link
Member Author

@publiclab/is-reviewers @jywarren please review this!

@codecov
Copy link

codecov bot commented Feb 21, 2020

Codecov Report

Merging #1634 into main will decrease coverage by 1.79%.
The diff coverage is 47.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1634      +/-   ##
==========================================
- Coverage   66.67%   64.88%   -1.80%     
==========================================
  Files         130      135       +5     
  Lines        2686     2828     +142     
  Branches      433      458      +25     
==========================================
+ Hits         1791     1835      +44     
- Misses        895      993      +98     
Impacted Files Coverage Δ
src/CliUtils.js 37.50% <0.00%> (ø)
src/Modules.js 100.00% <ø> (ø)
src/modules/EdgeDetect/Module.js 100.00% <ø> (ø)
src/modules/WebglDistort/Module.js 2.29% <0.00%> (ø)
src/modules/ColorHalftone/Module.js 3.63% <3.63%> (ø)
src/modules/Overlay/Module.js 93.18% <94.11%> (-1.69%) ⬇️
src/modules/ColorHalftone/index.js 100.00% <100.00%> (ø)
src/modules/Colorbar/Module.js 100.00% <100.00%> (ø)
src/modules/Crop/Module.js 88.88% <100.00%> (ø)
src/modules/EdgeDetect/EdgeUtils.js 86.81% <100.00%> (-0.15%) ⬇️
... and 7 more

@harshkhandeparkar
Copy link
Member

Can you explain, in brief, what caused this and how you fixed it? Thanks.

@rishabhshuklax
Copy link
Member Author

@harshkhandeparkar The error was because the syntax for taking input in CLI was

./index.js -s "webgl-distort" -c '{"nw":"100,100","se":"40,40"}' -i examples/images/test.png

So I rewrote how the inputs were taken to support the following syntax

./index.js -s "webgl-distort{nw:100%2C100|se:40%2C40}" -i examples/images/test.png

Similar to how we take inputs from URL hash.

@harshkhandeparkar
Copy link
Member

Oh so the CLI and URL input formats werr different.

input +
': ' +
options[input].desc
);
});

if (program.config) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was this and why was it removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was used to get input for options for different modules using -c flag, I removed this to support new format.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we can't directly give input? Or is there a different flag for it now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah just need clarification on this - thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:
./index.js -s "webgl-distort" -c '{"nw":"100,100","se":"40,40"}' -i examples/images/test.png
Now:
./index.js -s "webgl-distort{nw:100%2C100|se:40%2C40}" -i examples/images/test.png

So since we used to give options seperately therefore we needed the -c flag but now the option values are given inside the same string(just like the url) so it isn't needed anymore.

program.steps = sequencer.stringToJSON(program.step);

var stepNames = [];
program.step.split(',').forEach(v => stepNames.push(v.split('{')[0]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use array map function.
stepNames = program.step.split(',').map(....).

Let's make the code concise and modern.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea you're right, I will do that ASAP!

@gitpod-io
Copy link

gitpod-io bot commented Jul 7, 2020

@jywarren
Copy link
Member

jywarren commented Jul 7, 2020

Hi all! Just coming back to this, thank you so much! I hope you're all well.

I'm going to update this but I wonder if folks could help point out where CLI is tested out... i can't seem to find it and I just reorganized the test runners so I'd like to have a separate job for them alongside the others. Then fixes like this will also be easier to review and check tests for!

image

@jywarren
Copy link
Member

Just an update - now we can test this out on GitPod too, when you update the branch! We can actually open this now, above: https://gitpod.io/#https://github.com/publiclab/image-sequencer/pull/1634

Do you think you could add a basic CLI test? Perhaps we actually need a simple test file in a shell script. I'm going to try.

@jywarren
Copy link
Member

Noting that we should also link this to #1694 !

@jywarren
Copy link
Member

Shall we merge this after #1718, the CLI tests? Thanks!

@jywarren jywarren added this to the v3.7.0 milestone Oct 28, 2020
@daemon1024 daemon1024 mentioned this pull request Oct 30, 2020
7 tasks
@jywarren
Copy link
Member

jywarren commented Nov 1, 2020

Noting CLI tests now exist:

image

src/CliUtils.js Outdated Show resolved Hide resolved
Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far! Should we add a test demonstrating this using a pipe character?

input +
': ' +
options[input].desc
);
});

if (program.config) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah just need clarification on this - thanks!

@jywarren jywarren added this to In Progress in v3.7.0 via automation Nov 1, 2020
@harshkhandeparkar harshkhandeparkar removed this from the v3.7.0 milestone Nov 2, 2020
Copy link
Member

@harshkhandeparkar harshkhandeparkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the docs since you changed the syntax? Ty.

@jywarren
Copy link
Member

Hi all, just wondering what the status of this is now -- thank you!!!

@harshkhandeparkar harshkhandeparkar added the almost-complete PRs that are almost done but little more work. label Jul 27, 2021
@harshkhandeparkar harshkhandeparkar marked this pull request as draft July 27, 2021 21:12
@harshkhandeparkar harshkhandeparkar removed the almost-complete PRs that are almost done but little more work. label Jul 27, 2021
@jywarren jywarren removed this from In Progress in v3.7.0 Jan 25, 2022
@jywarren jywarren added this to In progress in v3.7.x via automation Jan 25, 2022
@jywarren jywarren added the bug label Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v3.7.x
In progress
3 participants