Commit 73d9cf82 authored by ∞'s avatar 💻

Rename Group to BaseGroup

parent 005f1be1
......@@ -5,6 +5,6 @@ from .exceptions import Cli2Exception, Cli2ArgsException
from .parser import Parser
from .introspection import docfile, Callable, Importable, DocDescriptor
from .command import command, option, Option
from .console_script import ConsoleScript, Group
from .console_script import ConsoleScript, BaseGroup
from .test import autotest
from .cli import debug, docmod, help, run
......@@ -8,7 +8,7 @@ or to execute callables or help working with cli2 itself.
import textwrap
import types
from .console_script import ConsoleScript, Group
from .console_script import ConsoleScript, BaseGroup
from .command import command, option
from .exceptions import Cli2ArgsException
from .colors import GREEN, RED, RESET, YELLOW
......@@ -20,7 +20,7 @@ def docmod(module_name):
Example: cli2 docmod cli2
"""
return Group.factory(module_name).doc
return BaseGroup.factory(module_name).doc
@command(color=GREEN)
......@@ -53,7 +53,7 @@ def help(*args):
'Showing help for',
importable.module.__name__ + RESET
])
yield Group.factory(importable.module.__name__).doc
yield BaseGroup.factory(importable.module.__name__).doc
@command(color=GREEN)
......
......@@ -45,7 +45,7 @@ class GroupDocDescriptor:
self.value = value
class Group(collections.OrderedDict):
class BaseGroup(collections.OrderedDict):
doc = GroupDocDescriptor()
def __init__(self, name, doc=None):
......@@ -80,12 +80,12 @@ class Group(collections.OrderedDict):
return cls(module_name, doc).add_module(module_name)
class ConsoleScript(Group):
class ConsoleScript(BaseGroup):
def __init__(self, doc=None, argv=None, default_command='help'):
ConsoleScript.singleton = self
self.default_command = default_command
argv = argv if argv is not None else sys.argv
Group.__init__(self, argv[0].split('/')[-1], doc)
super().__init__(argv[0].split('/')[-1], doc)
self.argv = argv
self.exit_code = 0
self.add_help()
......
......@@ -17,13 +17,13 @@ class Parser:
def parse(self):
from .introspection import Callable
from .console_script import Group
from .console_script import BaseGroup
for arg in self.argv_all:
if not self.command and arg in self.group:
item = self.group[arg]
if isinstance(item, Group):
if isinstance(item, BaseGroup):
self.group = item
elif isinstance(item, Callable):
self.command = item
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment