Skip to content

Commit

Permalink
help refactor - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jan 17, 2025
1 parent 7ecf128 commit e1af81a
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 154 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ graph LR

[![pylint](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-geo.svg)](https://pypi.org/project/blue-geo/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-geo)](https://pypistats.org/packages/blue-geo)

built by 🌀 [`blue_options-4.190.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.943.1`](https://github.com/kamangir/blue-geo).
built by 🌀 [`blue_options-4.190.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.944.1`](https://github.com/kamangir/blue-geo).
2 changes: 1 addition & 1 deletion blue_geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

DESCRIPTION = f"{ICON} AI for a Blue Planet."

VERSION = "4.943.1"
VERSION = "4.944.1"

REPO_NAME = "blue-geo"

Expand Down
2 changes: 1 addition & 1 deletion blue_geo/help/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from blue_options.terminal import show_usage

from blue_geo.catalog import get_catalog
from blue_geo.help.datacube import ingest_options
from blue_geo.help.datacube.ingest import ingest_options
from blue_geo.catalog.functions import get_datacube_class_in_catalog
from blue_geo.catalog.default import as_list_of_args
from blue_geo.catalog.classes import list_of_catalogs
Expand Down
138 changes: 0 additions & 138 deletions blue_geo/help/datacube.py

This file was deleted.

13 changes: 13 additions & 0 deletions blue_geo/help/datacube/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from blue_geo.help.datacube.crop import help_crop
from blue_geo.help.datacube.generate import help_generate
from blue_geo.help.datacube.get import help_get
from blue_geo.help.datacube.ingest import help_ingest, ingest_options, scope_details
from blue_geo.help.datacube.list import help_list

help_functions = {
"crop": help_crop,
"generate": help_generate,
"get": help_get,
"ingest": help_ingest,
"list": help_list,
}
20 changes: 20 additions & 0 deletions blue_geo/help/datacube/crop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import List

from blue_options.terminal import show_usage


def help_crop(
tokens: List[str],
mono: bool,
) -> str:
options = "download,dryrun,suffix=<suffix>"
return show_usage(
[
"@datacube crop",
f"[{options}]",
"[..|<object-name>]",
"[.|<datacube-id>]",
],
"crop <datacube-id> by <object-name>/target/shape.geojson -> <datacube-id>-DERIVED-crop-<suffix>.",
mono=mono,
)
28 changes: 28 additions & 0 deletions blue_geo/help/datacube/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import List

from blue_options.terminal import show_usage, xtra

from blue_geo.datacube.modalities import options as modality_options


def help_generate(
tokens: List[str],
mono: bool,
) -> str:
options = xtra("dryrun", mono)

args = [
"[--modality <{}>]".format("|".join(modality_options)),
"[--overwrite <1>]",
]

return show_usage(
[
"@datacube generate",
f"[{options}]",
"[.|<datacube-id>]",
]
+ args,
"generate datacube/<modality>.",
mono=mono,
)
20 changes: 20 additions & 0 deletions blue_geo/help/datacube/get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import List

from blue_options.terminal import show_usage


def help_get(
tokens: List[str],
mono: bool,
) -> str:
options = "catalog | raw | template"

return show_usage(
[
"@datacube get",
f"[{options}]",
"[.|<datacube-id>]",
],
"get datacube properties.",
mono=mono,
)
46 changes: 46 additions & 0 deletions blue_geo/help/datacube/ingest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from typing import List

from blue_options.terminal import show_usage, xtra

from blue_geo.catalog.generic.generic.scope import DatacubeScope


def ingest_options(mono: bool) -> str:
return "".join(
[
xtra("~copy_template,dryrun,overwrite,", mono),
"scope=<scope>",
xtra(",upload", mono),
]
)


scope_details = {
f"scope: {DatacubeScope.help}": [
"all: ALL files.",
"metadata (default): any < 1 MB.",
"raster: all raster.",
"rgb: rgb.",
"rgbx: rgb and what is needed to build rgb.",
"<suffix>: any *<suffix>.",
]
}


def help_ingest(
tokens: List[str],
mono: bool,
) -> str:
options = ingest_options(mono)

return show_usage(
[
"@datacube ingest",
f"[{options}]",
"[.|<datacube-id>]",
"[<args>]",
],
"ingest <datacube-id>/<scope>.",
scope_details,
mono=mono,
)
29 changes: 29 additions & 0 deletions blue_geo/help/datacube/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import List

from blue_options.terminal import show_usage

from blue_geo.help.datacube.ingest import scope_details


def help_list(
tokens: List[str],
mono: bool,
) -> str:
args = [
"[--count 1]",
"[--delim +]",
"[--exists 1]",
"[--log 0]",
"[--scope <scope>]",
]

return show_usage(
[
"@datacube list",
"[.|<datacube-id>]",
]
+ args,
"list datacube files.",
scope_details,
mono=mono,
)
Loading

0 comments on commit e1af81a

Please sign in to comment.