1

Invoke and Argparse are both python libraries for managing and executing python scripts. They both allow to deal with the case when the same script should be used in different ways (Argparse via add_subparsers, and Invoke via task). Eventually it comes down to just specifying the name of a task and the task's specific parameters when calling the script that contains multiple tasks.

But are there major differences in functionality between these two libraries? For instance, I'm used to Argparse. What useful thing does Invoke allow me to do that Argparse doesn't?

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
kurtosis
  • 1,365
  • 2
  • 12
  • 27
  • 1
    Why don't you just read the docs and try out by yourself ? – bruno desthuilliers Sep 15 '15 at 11:08
  • I'm doing exactly this, but maybe someone more experienced in `invoke` can share some non-trivial usages and tricks. Everything I can find about `argparse` vs `invoke` comparison on the `invoke` website is that the latter allows to run multiple tasks in one-liner, like this: `runner --core-opts task1 --task1-opts task2 --task2-opts` But it's not much trouble to just execute the script with `argparse` several times, each time specifying corresponding task. – kurtosis Sep 15 '15 at 11:20
  • I removed the `invoke` tag because it has nothing to do with the `Python` package that you are thinking of using. – hpaulj Sep 15 '15 at 15:44
  • `argparse` is a builtin module that many SO posters are familiar with. `invoke` is someone's development project that most of us have not heard of. Your best bet is to experiment with it, and contact the developer directly. – hpaulj Sep 15 '15 at 15:46

1 Answers1

0

One thing which immediately comes to my mind when thinking about Invoke vs Argparse is that the former makes it somewhat trivial to respond to program output.

Let's suppose that you want to run a sudo command, then Invoke can capture the terminal output and set a rule for example to respond to the prompt with a password. You can find out more in the Responders section of the official Invoke documentation.

https://docs.pyinvoke.org/en/stable/concepts/watchers.html

Eugen_R
  • 21
  • 4