(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
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:
- Modify args / kwargs before running them
- Replace
run()with a different subprocess runner
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()