From bd75ef42430e19691a50e7a66a937b049dba121a Mon Sep 17 00:00:00 2001 From: Kevin Horn Date: Thu, 31 Jul 2014 23:30:51 -0500 Subject: [PATCH] Add a root_app property to `cli.Application` This adds a property to `cli.Applicatino callled root_app which returns a reference to the "root" Application object in a tree of Application objects. --- plumbum/cli/application.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plumbum/cli/application.py b/plumbum/cli/application.py index ff429d7d9..ded78518c 100644 --- a/plumbum/cli/application.py +++ b/plumbum/cli/application.py @@ -137,6 +137,10 @@ def __init__(self, executable): self._switches_by_name[name] = swinfo self._switches_by_func[swinfo.func] = swinfo + @property + def root_app(self): + return (self.parent.root_app if self.parent else self) + @classmethod def unbind_switches(cls, *switch_names): """Unbinds the given switch names from this application. For example