Skip to content

Conversation

@jtenner
Copy link
Contributor

@jtenner jtenner commented Mar 28, 2020

Fixes #1063

Open to suggestions. This seems to do the trick though.

@jtenner
Copy link
Contributor Author

jtenner commented Mar 28, 2020

I used link locally and validated this works now.

@dcodeIO
Copy link
Member

dcodeIO commented Mar 28, 2020

What happens now if no first argument is provided, like just asinit?

@jtenner
Copy link
Contributor Author

jtenner commented Mar 28, 2020

PS C:\Users\Joshua Tenner\projects\test-project> npx asinit internal/validators.js:120 throw new ERR_INVALID_ARG_TYPE(name, 'string', value); ^ TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at validateString (internal/validators.js:120:11) at Object.resolve (path.js:139:9) at Object.<anonymous> (C:\Users\Joshua Tenner\projects\assemblyscript\bin\asinit:40:25) at Module._compile (internal/modules/cjs/loader.js:1147:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10) at Module.load (internal/modules/cjs/loader.js:996:32) at Function.Module._load (internal/modules/cjs/loader.js:896:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'ERR_INVALID_ARG_TYPE' } 
@jtenner
Copy link
Contributor Author

jtenner commented Mar 28, 2020

We should make that better. :)

@jtenner
Copy link
Contributor Author

jtenner commented Mar 28, 2020

Also, could it be possible to default to "." as the path instead of requiring passing a path?

Copy link

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

👍

@jtenner
Copy link
Contributor Author

jtenner commented Mar 31, 2020

All comments have been addressed. This is ready for review again.

@jtenner jtenner requested a review from dcodeIO March 31, 2020 15:56
@dcodeIO
Copy link
Member

dcodeIO commented Apr 1, 2020

Suggesting to make it so that the help message is shown if zero non-option arguments have been provided, similar to what asc and other tools are doing.

@webmaster128
Copy link

Suggesting to make it so that the help message is shown if zero non-option arguments have been provided, similar to what asc and other tools are doing.

Such that

asinit --yes # defaults to . asinit . # runs interactively asinit # fails with help message 

? That would be a somewhat strange compisition of flags and positional argument. So I guess we'd have to give up the default value for the folder.

No strong opinion here, but my intuition is that asinit should run interactively in the current folder.

@jtenner
Copy link
Contributor Author

jtenner commented Apr 1, 2020

I'm with @webmaster128 on this opinion, but I'm probably going to change it so that it shows the help screen with 0 arguments.

@dcodeIO
Copy link
Member

dcodeIO commented Apr 1, 2020

What I'm proposing is

asinit --yes # fails with help message asinit # fails with help message asinit . # runs interactively asinit --yes . # runs without asking 

The check is basically !arguments.length, ignoring any options, so exactly what asc is doing.

@webmaster128
Copy link

Okay, yeah, this is the giving up the default value for the folder route. I'm not a big fan of this, but it is consistent and makes sense in code and to the user. Go for it.

@jtenner
Copy link
Contributor Author

jtenner commented Apr 1, 2020

Sorry for the delay. I had other things to work on.

I verified the proposal works by testing each input as suggested by @dcodeIO .

asinit --yes # fails with help message asinit # fails with help message asinit . # runs interactively asinit --yes . # runs without asking 
@dcodeIO
Copy link
Member

dcodeIO commented Apr 2, 2020

Thanks! But please reset the changes to package-lock before I merge :)

@jtenner
Copy link
Contributor Author

jtenner commented Apr 2, 2020

This should be all set now. Sorry for the trouble. Merge? 🙂

@dcodeIO dcodeIO merged commit f25623a into AssemblyScript:master Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants