Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dlespiau
Copy link
Member

@dlespiau dlespiau commented Feb 4, 2019

Having typed input parameters on the command line seems a bit overkill and leads to a poor UX. We already define the type of the parameter in code, we can keep that as the canonical type we want and coerce strings from the command line into the right type.

Specifying an input parameter on the command line now looks like:

jk run -p foo=2 -p bar=true script.js

There was a bit of work to get there:

  • wire the potential error from std.param back to the js side
  • coerce strings to numbers/bool as requested
  • Adapt the e2e tests to the UX change

Fixes: #102

We'd like to do type conversion live and throw an error.
We don't want to throw an error when the parameter doesn't exist but return the
default value. Ensure that the behaviour is tested.
It's not actually a fd leak, but might as well do it properly.
Having typed input parameters on the command line seems a bit overkill and
leads to a poor UX. We already define the type of the parameter in code, we can
keep that as the canonical type we want and coerce strings from the command
line into the right type.

Fixes: #102
This gives more visibility into what's going wrong.

  Error: invalid type for param 'mybool': cannot convert "foo" to bool
@dlespiau dlespiau force-pushed the 2019-02-04-moar-params-work branch from 67002b4 to efc820e Compare February 4, 2019 19:12
Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

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

👍

At the moment, the failure condition looks like:

    Error: Should be true

Adding more details can help understanding what's going wrong, eg.

    Error: Should be true
    Messages: fork/exec : no such file or directory
@dlespiau
Copy link
Member Author

dlespiau commented Feb 5, 2019

Added a small improvement to the e2e tests that I stumbled onto when adding the new test in this PR. Will merge once the tests pass.

@dlespiau dlespiau merged commit 3ce4b8e into master Feb 5, 2019
@dlespiau dlespiau deleted the 2019-02-04-moar-params-work branch February 5, 2019 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants