Skip to content

Allow the easy creation of executable utilities with invoke. #173

@sophacles

Description

@sophacles

Description

Splitting this ticket from #170 at the request of @bitprophet

It would be nice to easily create scripts that I can place in my $PATH that internally use invoke, but are named according to script functionality. Some rational (copied from referenced ticket discussion):

I could probably train myself always to do:

inv -c /path/to/source/tree/utils/$TASK ....

But I kind of like having them:

  1. as a script available in my $PATH
  2. as tools named cognitively, just like when I'm using busybox... i just link (e.g) ls and cp rather than calling busybox ls ... or busybox cp file1 file2
  3. in a consistent place (depending on what I'm doing, the source tree where the task files live can vary. It's in one place on my dev machine, and different places in deployment depending on what OS, nfs details, and so on. We're still working out our "one true deployment strategy" so this changes as stuff comes up).

Also noteworthy, several of my targets are most commonly called from places in the system that are not the directory where invoke lives.

Currently I do this via the code in this gist: https://gist.github.com/sophacles/c17ce33a14d582dfa268 and creating scripts entry points in a setup.py.


To-do list

[Note: this part of the ticket is being maintained by @bitprophet]

  • Parameterization of version number by itself (not name+version as we currently do)
  • Parameterization of tool/package name, defaulting to the name seen in argv[0]
    • Capitalized in --version output, e.g. Invoke 1.2
    • Allowance for arbitrary additional lines of version info, e.g. for Fabric wanting to display its + Paramiko's, and even e.g. other data like Python version?
    • Left as-is in --help output, e.g. inv[oke] --core-opts ...
    • Is there an automated way to determine inv vs invoke vs etc? We don't have access to setuptools' data at runtime, so we'll probably have to provide this manually. (Maybe stored in similar fashion as version - reused in both spots?)
  • Ability to update global --help to include elements of --list, i.e. for tools distributing with built-in tasks as subcommands (which would be...most of them...Fabric is actually unusual in this regard).
    • I.e. probably sticking --list type output above the core flags, which is what most real subcommand based CLI apps tend to do (see git, pip etc)
  • Fix up per-task help to honor the dynamic program name (it's hardcoded right now, as above)
  • Ability to override which flags are presented and/or their default values

Cleanup:

  • Check all the task modules in _support to remove any no longer in use (& consolidate some if possible)
  • Check all methods in _utils.py for whether they've gone out of use
  • Ensure docs build & the docstrings recently added look good rendered

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions