Skip to content

Commit

Permalink
hello world 👋🏽 - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jun 16, 2024
1 parent 83796e6 commit 45c38a0
Show file tree
Hide file tree
Showing 38 changed files with 128 additions and 129 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/bashtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ function bashtest() {
}

bashtest "$@"


3 changes: 2 additions & 1 deletion .github/workflows/bashtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
echo "ABCLI_AWS_RDS_HOST: $ABCLI_AWS_RDS_HOST"
echo "ABCLI_AWS_RDS_PASSWORD: $ABCLI_AWS_RDS_PASSWORD"
./.github/workflows/bashtest.sh blue_plugin
./.github/workflows/bashtest.sh blue_geo
2 changes: 2 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ jobs:
- name: Analysing the code with pylint
run: |
pylint -d W1203,C0103,C0111,C0114,C0305,C0115,C0116,C0411,W0404,W0237,C0209,C0415,W0621,W0702,W0102,W1202,E0401,W1514,C3002,W0401,W0611,C0413,C0412,W0603,R0911,E1101,W0622,R1721,W0718,R1728,C3001,R0801,R0401,R0914,R0913,R0915,W0123,R0912,C0301,W0511,W0105,W0613,R0902,R0903,R1735,W1401,W3101,W1308,E1102 $(git ls-files '*.py')
2 changes: 2 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ jobs:
echo "ABCLI_AWS_RDS_PASSWORD: $ABCLI_AWS_RDS_PASSWORD"
echo "BLUE_PLUGIN_SECRET: $BLUE_PLUGIN_SECRET"
pytest
39 changes: 1 addition & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1 @@
# 🌀 blue-plugin

🌀 `blue-plugin` is a git template for an 🚀 [`awesome-bash-cli`](https://github.com/kamangir/awesome-bash-cli) (`abcli`) plugin, to build [things like these](https://github.com/kamangir?tab=repositories), that out-of-the-box support,

- a git repo with actions.
- [pytest](https://docs.pytest.org/).
- [pylint](https://pypi.org/project/pylint/).
- a python package.
- [pypi](https://pypi.org/).
- a bash interface.
- bash testing.

## installation

```bash
pip install blue-plugin
```

## creating a blue-plugin

1️⃣ create a new repository from [this template](https://github.com/kamangir/blue-plugin),

2️⃣ complete `<repo-name>` and `<plugin-name>` and run,

```bash
@git clone <repo-name> cd

@plugins transform <repo-name>

@init
<plugin-name> help
```

---

[![PyPI version](https://img.shields.io/pypi/v/blue-plugin.svg)](https://pypi.org/project/blue-plugin/)

To use on [AWS SageMaker](https://aws.amazon.com/sagemaker/) replace `<plugin-name>` with the name of the plugin and follow [these instructions](https://github.com/kamangir/notebooks-and-scripts/blob/main/SageMaker.md).
# blue_geo
File renamed without changes.
6 changes: 4 additions & 2 deletions blue_plugin/.abcli/abcli.sh → blue_geo/.abcli/abcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
abcli_source_path - caller,suffix=/tests

abcli_env dot load \
plugin=blue_plugin
plugin=blue_geo
abcli_env dot load \
filename=blue_plugin/config.env,plugin=blue_plugin
filename=blue_geo/config.env,plugin=blue_geo


8 changes: 8 additions & 0 deletions blue_geo/.abcli/actions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /usr/bin/env bash

function blue_geo_action_git_before_push() {
[[ "$(abcli_git get_branch)" == "main" ]] &&
blue_geo pypi build
}


4 changes: 3 additions & 1 deletion blue_plugin/.abcli/aka.sh → blue_geo/.abcli/aka.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env bash

function bp() {
blue_plugin "$@"
blue_geo "$@"
}


18 changes: 10 additions & 8 deletions blue_plugin/.abcli/blue_plugin.sh → blue_geo/.abcli/blue_geo.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#! /usr/bin/env bash

function blue_plugin() {
function blue_geo() {
local task=$(abcli_unpack_keyword $1 help)

if [ $task == "help" ]; then
blue_plugin_leaf "$@"
blue_plugin_node "$@"
blue_plugin task "$@"
blue_geo_leaf "$@"
blue_geo_node "$@"
blue_geo task "$@"
return
fi

if [ "$task" == "task" ]; then
local options=$2
if [ $(abcli_option_int "$options" help 0) == 1 ]; then
abcli_show_usage "blue_plugin task [<thing_1+thing_2>|all]" \
abcli_show_usage "blue_geo task [<thing_1+thing_2>|all]" \
"task things."
return
fi

local what=$(abcli_option "$options" what what)

python3 -m blue_plugin \
python3 -m blue_geo \
task \
--what "$what" \
"${@:3}"
Expand All @@ -29,8 +29,10 @@ function blue_plugin() {
fi

abcli_generic_task \
plugin=blue_plugin,task=$task \
plugin=blue_geo,task=$task \
"${@:2}"
}

abcli_log $(blue_plugin version --show_icon 1)
abcli_log $(blue_geo version --show_icon 1)


9 changes: 9 additions & 0 deletions blue_geo/.abcli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /usr/bin/env bash

function abcli_install_blue_geo() {
:
}

abcli_install_module blue_geo 1.1.1


10 changes: 6 additions & 4 deletions blue_plugin/.abcli/leaf.sh → blue_geo/.abcli/leaf.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#! /usr/bin/env bash

function blue_plugin_leaf() {
function blue_geo_leaf() {
local options=$1

if [ $(abcli_option_int "$options" help 0) == 1 ]; then
local options="dryrun,upload"
local args="[--<keyword> <value>]$ABCUL[--<keyword> <value>]"
abcli_show_usage "blue_plugin leaf$ABCUL[$options]$ABCUL<object-name>$ABCUL$args" \
"blue-plugin leaf <object-name>."
abcli_show_usage "blue_geo leaf$ABCUL[$options]$ABCUL<object-name>$ABCUL$args" \
"blue-geo leaf <object-name>."
return
fi

echo "blue-plugin: leaf: 🪄"
echo "blue-geo: leaf: 🪄"
}


10 changes: 6 additions & 4 deletions blue_plugin/.abcli/node.sh → blue_geo/.abcli/node.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#! /usr/bin/env bash

function blue_plugin_node() {
function blue_geo_node() {
local task=$(abcli_unpack_keyword $1 help)

if [ "$task" == "help" ]; then
blue_plugin_node_leaf "$@"
blue_geo_node_leaf "$@"
return
fi

local function_name=blue_plugin_node_$task
local function_name=blue_geo_node_$task
if [[ $(type -t $function_name) == "function" ]]; then
$function_name "${@:2}"
return
fi

abcli_log_error "-blue_plugin: node: $task: command not found."
abcli_log_error "-blue_geo: node: $task: command not found."
return 1
}

abcli_source_path - caller,suffix=/node


10 changes: 6 additions & 4 deletions blue_plugin/.abcli/node/leaf.sh → blue_geo/.abcli/node/leaf.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#! /usr/bin/env bash

function blue_plugin_node_leaf() {
function blue_geo_node_leaf() {
local options=$1

if [ $(abcli_option_int "$options" help 0) == 1 ]; then
options="~download,dryrun,~upload"
local args="[--<keyword-1> <value>]$ABCUL[--<keyword-2> <value>]"
abcli_show_usage "blue_plugin node leaf$ABCUL[$options]$ABCUL[.|<object-name-1>]$ABCUL[-|<object-name-2>]$ABCUL$args" \
"<object-name-1> -[blue-plugin node leaf]-> <object-name-2>."
abcli_show_usage "blue_geo node leaf$ABCUL[$options]$ABCUL[.|<object-name-1>]$ABCUL[-|<object-name-2>]$ABCUL$args" \
"<object-name-1> -[blue-geo node leaf]-> <object-name-2>."
return
fi

Expand All @@ -23,7 +23,7 @@ function blue_plugin_node_leaf() {
local object_name_2=$(abcli_clarify_object $4 $(abcli_string_timestamp))

abcli_eval dryrun=$do_dryrun \
python3 -m blue_plugin.node \
python3 -m blue_geo.node \
leaf \
--object_name_1 $object_name_1 \
--object_name_2 $object_name_2 \
Expand All @@ -32,3 +32,5 @@ function blue_plugin_node_leaf() {
[[ "$do_dryrun" == 1 ]] &&
abcli_upload - $object_name_2
}


12 changes: 12 additions & 0 deletions blue_geo/.abcli/tests/thing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env bash

function test_blue_geo_thing() {
local options=$1

local test_options=$2

abcli_eval ,$options \
"echo 📜 blue-geo: test: thing: $test_options: ${@:3}."
}


Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

function test_blue_plugin_thing_with_args() {
function test_blue_geo_thing_with_args() {
local options=$1
local do_dryrun=$(abcli_option_int "$options" dryrun 0)

Expand All @@ -12,3 +12,5 @@ function test_blue_plugin_thing_with_args() {
echo "🪄 $arg"
done
}


Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#! /usr/bin/env bash

function test_blue_plugin_version() {
function test_blue_geo_version() {
local options=$1

abcli_eval ,$options \
"blue_plugin version ${@:2}"
"blue_geo version ${@:2}"

return 0
}


9 changes: 9 additions & 0 deletions blue_geo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NAME = "blue_geo"

ICON = "🌐"

DESCRIPTION = f"{ICON} AI for precise geospatial data analysis and visualization."

VERSION = "4.2.1"

REPO_NAME = "blue-geo"
6 changes: 4 additions & 2 deletions blue_plugin/__main__.py → blue_geo/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from blue_plugin import NAME, VERSION, DESCRIPTION, ICON
from blue_plugin.logger import logger
from blue_geo import NAME, VERSION, DESCRIPTION, ICON
from blue_geo.logger import logger
from blueness.argparse.generic import main

success, message = main(__file__, NAME, VERSION, DESCRIPTION, ICON)
if not success:
logger.error(message)


File renamed without changes.
2 changes: 2 additions & 0 deletions blue_plugin/env.py → blue_geo/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
"BLUE_PLUGIN_CONFIG",
"",
)


2 changes: 2 additions & 0 deletions blue_geo/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


4 changes: 3 additions & 1 deletion blue_plugin/logger.py → blue_geo/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from abcli.logger import get_logger
from blue_plugin import ICON
from blue_geo import ICON

logger = get_logger(ICON)


5 changes: 5 additions & 0 deletions blue_geo/node/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from blue_geo import NAME

NAME = f"{NAME}.node"


10 changes: 6 additions & 4 deletions blue_plugin/node/__main__.py → blue_geo/node/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import argparse
from blue_plugin import VERSION
from blue_plugin.node import NAME
from blue_plugin.node.functions import func
from blue_plugin.logger import logger
from blue_geo import VERSION
from blue_geo.node import NAME
from blue_geo.node.functions import func
from blue_geo.logger import logger
from blueness.argparse.generic import sys_exit

parser = argparse.ArgumentParser(NAME, description=f"{NAME}-{VERSION}")
Expand All @@ -26,3 +26,5 @@
success = None

sys_exit(logger, NAME, args.task, success)


4 changes: 3 additions & 1 deletion blue_plugin/node/functions.py → blue_geo/node/functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from blue_plugin.logger import logger
from blue_geo.logger import logger


def func(arg: str) -> bool:
logger.info(f"arg:{arg}")
return True


6 changes: 4 additions & 2 deletions blue_plugin/tests/test_env.py → blue_geo/tests/test_env.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from abcli.tests import test_env
from blue_plugin import env
from blue_geo import env


def test_abcli_env():
test_env.test_abcli_env()


def test_blue_plugin_env():
def test_blue_geo_env():
assert env.BLUE_PLUGIN_SECRET
assert env.BLUE_PLUGIN_CONFIG


Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ def test_thing(
object_name = unique_object()

assert object_name


Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from blue_plugin import VERSION
from blue_geo import VERSION


def test_version():
assert VERSION


2 changes: 2 additions & 0 deletions blue_plugin/urls.py → blue_geo/urls.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
urlpatterns = []


6 changes: 0 additions & 6 deletions blue_plugin/.abcli/actions.sh

This file was deleted.

7 changes: 0 additions & 7 deletions blue_plugin/.abcli/install.sh

This file was deleted.

Loading

0 comments on commit 45c38a0

Please sign in to comment.