Seperated argument parser creation from main kas entry point

With Sphinx it is possible to create the command line documentation
automatically if there is a function that returns just the command line
parser.

Currently the creation of the argument parser is rather entangled with
the rest of kas. This patches seperates this.

Signed-off-by: Claudius Heine <ch@denx.de>
This commit is contained in:
Claudius Heine
2017-06-28 14:48:41 +02:00
committed by Daniel Wagner
parent 546b51f450
commit 503fd3d47a
4 changed files with 49 additions and 15 deletions

View File

@@ -25,6 +25,7 @@
"""
import subprocess
from kas.libkas import kasplugin
from kas.config import load_config
from kas.libcmds import (Macro, Command, SetupProxy, SetupEnviron, SetupHome)
@@ -32,12 +33,17 @@ __license__ = 'MIT'
__copyright__ = 'Copyright (c) Siemens AG, 2017'
@kasplugin
class Shell:
"""
Implements a kas plugin that opens a shell within the kas environment.
"""
def __init__(self, parser):
@classmethod
def get_argparser(cls, parser):
"""
Returns a parser for the shell plugin
"""
sh_prs = parser.add_parser('shell')
sh_prs.add_argument('config',