From cc4bf97ae881e81963eb6ea173890faf2b6c9869 Mon Sep 17 00:00:00 2001 From: kamangir Date: Sun, 5 Jan 2025 12:51:26 -0800 Subject: [PATCH] @help refactor - kamangir/bolt#746 --- README.md | 2 +- abcli/.abcli/plugins/build_README.sh | 11 ----------- abcli/.abcli/tests/help.sh | 2 ++ abcli/__init__.py | 2 +- abcli/help/build_README.py | 26 ++++++++++++++++++++++++++ abcli/help/generic.py | 6 ++++++ 6 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 abcli/help/build_README.py diff --git a/README.md b/README.md index c8d4bef6..c15e56af 100644 --- a/README.md +++ b/README.md @@ -63,4 +63,4 @@ create a copy of [`sample.env`](./abcli/sample.env) as `.env` and fill in the se [![pylint](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/awesome-bash-cli/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/awesome-bash-cli/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/awesome-bash-cli/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/abcli.svg)](https://pypi.org/project/abcli/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/abcli)](https://pypistats.org/packages/abcli) -built by 🌀 [`blue_options-4.174.1`](https://github.com/kamangir/awesome-bash-cli), based on 🪄 [`abcli-9.444.1`](https://github.com/kamangir/awesome-bash-cli). +built by 🌀 [`blue_options-4.174.1`](https://github.com/kamangir/awesome-bash-cli), based on 🪄 [`abcli-9.445.1`](https://github.com/kamangir/awesome-bash-cli). diff --git a/abcli/.abcli/plugins/build_README.sh b/abcli/.abcli/plugins/build_README.sh index 3bb319d4..41297dd8 100644 --- a/abcli/.abcli/plugins/build_README.sh +++ b/abcli/.abcli/plugins/build_README.sh @@ -2,18 +2,7 @@ function abcli_build_README() { local options=$1 - local plugin_name=$(abcli_option "$options" plugin abcli) - - if [ $(abcli_option_int "$options" help 0) == 1 ]; then - options="push" - [[ "$plugin_name" == "abcli" ]] && - options="$options,plugin=" - abcli_show_usage "$plugin_name build_README [$options]" \ - "build $plugin_name/README.md." - return - fi - local do_push=$(abcli_option_int "$options" push 0) local repo_name=$(abcli_unpack_repo_name $plugin_name) diff --git a/abcli/.abcli/tests/help.sh b/abcli/.abcli/tests/help.sh index aa2f9015..e35e2a79 100644 --- a/abcli/.abcli/tests/help.sh +++ b/abcli/.abcli/tests/help.sh @@ -15,6 +15,8 @@ function test_abcli_help() { \ "@browse" \ \ + "@build_README" \ + \ "@cat" \ \ "@docker browse " \ diff --git a/abcli/__init__.py b/abcli/__init__.py index c409e230..1c74956c 100644 --- a/abcli/__init__.py +++ b/abcli/__init__.py @@ -6,7 +6,7 @@ DESCRIPTION = f"{ICON} a language to speak AI." -VERSION = "9.444.1" +VERSION = "9.445.1" REPO_NAME = "awesome-bash-cli" diff --git a/abcli/help/build_README.py b/abcli/help/build_README.py new file mode 100644 index 00000000..da381e9f --- /dev/null +++ b/abcli/help/build_README.py @@ -0,0 +1,26 @@ +from typing import List + +from blue_options.terminal import show_usage, xtra + + +def help_build_README( + tokens: List[str], + mono: bool, + plugin_name: str = "abcli", +) -> str: + options = "push" + + callable = f"{plugin_name} build_README" + + if plugin_name == "abcli": + options = f"{options},plugin=" + callable = "@build_README" + + return show_usage( + callable.split(" ") + + [ + f"[{options}]", + ], + f"build {plugin_name}/README.md.", + mono=mono, + ) diff --git a/abcli/help/generic.py b/abcli/help/generic.py index 7957e662..06f3e49a 100644 --- a/abcli/help/generic.py +++ b/abcli/help/generic.py @@ -1,5 +1,6 @@ from typing import List, Dict, Callable, Union +from abcli.help.build_README import help_build_README from abcli.help.pypi import help_functions as help_pypi from abcli.help.pylint import help_pylint from abcli.help.pytest import help_pytest @@ -10,6 +11,11 @@ def help_functions( plugin_name: str = "abcli", ) -> Union[Callable, Dict[str, Union[Callable, Dict]]]: return { + "build_README": lambda tokens, mono: help_build_README( + tokens, + mono=mono, + plugin_name=plugin_name, + ), "pypi": help_pypi(plugin_name=plugin_name), "pylint": lambda tokens, mono: help_pylint( tokens,