-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ⬆️ Upgrade python-slugify to ^0.8 * 💥 Use argx instead of pyparam * ✅ Fix tests * 🔖 0.4.0 * 👷 Add python3.11 to CI * 👷 Remove python3.11 from CI
- Loading branch information
Showing
17 changed files
with
403 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .cli._main import main | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
"""Provide Cli class""" | ||
from __future__ import annotations | ||
|
||
from abc import ABC, abstractmethod, abstractproperty | ||
from typing import TYPE_CHECKING, Any, List, Mapping | ||
from typing import TYPE_CHECKING | ||
|
||
from simplug import Simplug | ||
|
||
from ..defaults import CLI_ENTRY_GROUP | ||
|
||
if TYPE_CHECKING: # pragma: no cover | ||
from pyparam import Params | ||
if TYPE_CHECKING: | ||
from argx import ArgumentParser | ||
from argparse import Namespace | ||
|
||
cli_plugin = Simplug(CLI_ENTRY_GROUP) | ||
|
||
|
||
class CLIPlugin(ABC): | ||
"""The abc for cli plugin""" | ||
|
||
def __init__( | ||
self, | ||
parser: ArgumentParser, | ||
subparser: ArgumentParser, | ||
) -> None: | ||
self.parser = parser | ||
self.subparser = subparser | ||
|
||
@abstractproperty | ||
def name(self) -> str: | ||
"""The name/command of this plugin""" | ||
|
||
@abstractproperty | ||
def params(self) -> "Params": | ||
"""Define parameters""" | ||
def define_args(self, parser: ArgumentParser): | ||
"""Define arguments for the command""" | ||
|
||
@abstractmethod | ||
def exec_command(self, args: Mapping[str, Any]) -> None: | ||
def exec_command(self, args: Namespace) -> None: | ||
"""Execute the command""" | ||
|
||
def parse_args(self, args: List[str]) -> Mapping[str, Any]: | ||
"""Parse the arguments""" | ||
return self.params.parse(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.