Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 1.57 KB

File metadata and controls

77 lines (51 loc) · 1.57 KB

(cmd)=

libvcs.cmd

Compare to: fabtools.git, salt.modules.git, ansible.builtin.git

:::{warning}

All APIs are considered experimental and subject to break pre-1.0. They can and will break between versions.

:::

:caption: API

git
hg
svn

Controlling commands

Override run()

You want to control stdout, stderr, terminal output, tee'ing or logging, introspect and modify the commands themselves. libvcs is designed to make this trivial to control.

  • Git -> Git.<command> -> Git.run -> run

You override Git.run method, and all Git commands can be intercepted.

class MyGit(Git):
    def run(self, *args, **kwargs):
        return ...

You can also pass-through using super()

class MyGit(Git):
    def run(self, *args, **kwargs):
        return super().run(*args, **kwargs)

Two possibilities:

  1. Modify args / kwargs before running them
  2. Replace run() with a different subprocess runner

LazySubprocessMixin

class MyGit(Git, LazySubprocessMixin):
    def run(self, *args, **kwargs):
        return ...

You can introspect it here.

Instead of git.run(...) you'd do git.run(...).run().

Also, you can introspect and modify the output before execution

>>> mycmd = git.run(...)
>>> mycmd.flags
...
>>> mycmd.flags = '--help'
>>> mycmd.run()