rliebz / tusk

The modern task runner
https://rliebz.github.io/tusk/
MIT License
237 stars 21 forks source link

support for user-prompt #66

Open Hobart2967 opened 4 years ago

Hobart2967 commented 4 years ago

Is your feature request related to a problem? Please describe. I'd like to see an option where a user is asked for an option in order to make the cli interactively.

Describe the solution you'd like

tasks: 
  setup:
    run: 
      - prompt:
           msg: "Please enter an api key:"
           type: string
           default: "foobar"
           var: api-key
      - command: |
           echo "export API_KEY=\'"${apiKey}\"" >>> ~/.bashrc
      - prompt: 
           msg: "Do you want to delete /home?"
           type: boolean
           default: true
           var: delete-home
       - when:
            equal: { delete-home: true }
            - command: rm -rf /home

Result:

user@machine # tusk
Please enter an api key [foobar]: barfoo
Do you want to delete /home? [Y/n]: n
rliebz commented 4 years ago

Thanks for opening this!

I think the resolution to this issue and https://github.com/rliebz/tusk/issues/43 are potentially the same feature. I like the suggestion in this comment to tie prompting to option values, since that effectively means a prompt can have all the flexibility that any other option can have.