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

[Q] How to pass the arguments? #66

Open
stagefright5 opened this issue Sep 14, 2020 · 11 comments
Open

[Q] How to pass the arguments? #66

stagefright5 opened this issue Sep 14, 2020 · 11 comments

Comments

@stagefright5
Copy link

stagefright5 commented Sep 14, 2020

How to pass arguments for the scripts. For example,

npm run abc -- a1=v1 a2=v2

How do I do this when executing a script through ntl?

@ruyadorno
Copy link
Owner

ruyadorno commented Sep 28, 2020

There's no way to do that currently - That said I would love to hear some ideas on how to better implement forwarding arguments to scripts as I def think it would make sense to support it 😊

@stagefright5
Copy link
Author

Hi,
I just saw your reply. I would be happy to contribute but, I am quite busy till this month's end. I will try to do something over the weekend. Thanks for considering.

@ruyadorno
Copy link
Owner

I gave it some thought and I think a very good UX for this would be something like:

$ ntl -i
⬢  Node Task List
? Select a task to run: (Use arrow keys)
❯ start › node scripts/start.js
   test › node test/test.js
   menu › ntl -i

and then allowing users to enter an edit mode by hitting a specific key, let's say E:

$ ntl -i
⬢  Node Task List
? Select a task to run: (Use arrow keys)
❯ EDITING: start › node scripts/start.js --build▌
   test › node test/test.js
   menu › ntl -i

Then once they hit ENTER we run this modified script instead, we could even go a step further and save it to the history of commands so that if when you run nt you run that same last command you just tweaked, also add some aliases to the ntl menu that will maybe be ephemeral to the duration of that session (idk)? Following up from the previous example, showing a menu like this the next time they run ntl:

$ ntl -i
⬢  Node Task List
? Select a task to run: (Use arrow keys)
❯ start(1) › node scripts/start.js --build
     start › node scripts/start.js
      test › node test/test.js
      menu › ntl -i

I realize this might be a bit too much and even require some playing with Inquirer.js internals but I just wanted to lay out the ideas I've had 😊 I'm still open to suggestions, feedback and will consider any contribution you want to submit 😄

@sergeyblohin
Copy link

sergeyblohin commented Dec 15, 2020

I need this functionality too.
I suggest next solution.
Run ntl with argument ntl --argument or ntl -a.
After run we choice task, hit Enter and type arguments for the script.

Normal mode:

$ ntl
⬢  Node Task List
? Select a task to run: (Use arrow keys or type to search)
❯ first:script
  second:script

With arguments mode:

$ ntl --argument
⬢  Node Task List
? Select a task to run: (Use arrow keys or type to search)
❯ first:script
  second:script
? Type argument for first:script: --argument foo

> running: first:script --argument foo

I think the idea is clear.

p. s.: Sorry for my english

@ruyadorno
Copy link
Owner

thank you so much @sergeyblohin! YES, your idea is clear and I think it's even better than what I previously proposed!

Having a second prompt is not only much easier to implement but also probably more intuitive for the majority of users 😊 I also think having an argument (such as --argument and -a) is better, although I still think supporting a magic key (such as E) can also be very helpful.

I already have a local branch started and will probably have some time to wrap up work on it soon 😄

@BananaAcid
Copy link

BananaAcid commented Jan 7, 2021

i thought it would be cool to add the required params next to the ntl.descriptions in the project.json, so ntl could ask ( pompt for each one like @sergeyblohin mentioned) for the param by showing its name:

ntl.parameters {
"start": ["--ip", "-p", "-x"]
}

@ruyadorno
Copy link
Owner

ruyadorno commented Feb 19, 2021

@BananaAcid that looks a little bit more evolved than what I'm planning to land at first but I can see the value and maybe we can follow up with something similar to that in the future.

It's been hard to find the time to wrap this up but I would like to provide some updates to anyone still keeping an eye on this, I have a working version of the second prompt as proposed by @sergeyblohin which for now only allows editing the arguments when pressing e (I personally find this more useful since I often only remember I wanted to edit an arg once I see the interface).

To give it a try now, install from the development branch:

$ npm install -g ruyadorno/ntl#task-editing

It would be awesome to gather some feedback on it before shipping 😊

@trsrm
Copy link

trsrm commented Dec 26, 2021

Any updates on this?

@ruyadorno
Copy link
Owner

for now I'd appreciate any feedback from folks with different environments, you can give it a quick try using npx:

$ npx ruyadorno/ntl#task-editing

but ideally before shipping I'd also like to add support to cli arguments as @sergeyblohin suggested previously

@BananaAcid
Copy link

for now I'd appreciate any feedback from folks with different environments, you can give it a quick try using npx:

$ npx ruyadorno/ntl#task-editing

but ideally before shipping I'd also like to add support to cli arguments as @sergeyblohin suggested previously

I am not sure, what feature is new and how to test it - could you give an example?

@ruyadorno
Copy link
Owner

I am not sure, what feature is new and how to test it - could you give an example?

For now the main thing there is an "Edit script" interface that aims to solve the problem stated at the origin of this thread (being able to pass arguments to scripts), to use it you simply hit (e) when the selector is over the item you desired to pass arguments to in the list.

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

No branches or pull requests

5 participants