diff --git a/platformio/commands/__init__.py b/platformio/commands/__init__.py index f6bac830..fac8e238 100644 --- a/platformio/commands/__init__.py +++ b/platformio/commands/__init__.py @@ -77,4 +77,10 @@ class PlatformioCLI(click.MultiCommand): from platformio.commands.project import project_init return project_init + + if name == "package": + from platformio.commands.pkg import cli + + return cli + raise AttributeError() diff --git a/platformio/commands/package.py b/platformio/commands/pkg.py similarity index 60% rename from platformio/commands/package.py rename to platformio/commands/pkg.py index c131da13..a4baba48 100644 --- a/platformio/commands/package.py +++ b/platformio/commands/pkg.py @@ -12,9 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import +import click -import platformio.package.commands.pack -import platformio.package.commands.publish -import platformio.package.commands.unpublish -from platformio.package.commands import cli +from platformio.package.commands.pack import package_pack_cmd +from platformio.package.commands.publish import package_publish_cmd +from platformio.package.commands.unpublish import package_unpublish_cmd + + +@click.group( + "pkg", + commands=[ + package_pack_cmd, + package_publish_cmd, + package_unpublish_cmd, + ], + short_help="Package Manager", +) +def cli(): + pass diff --git a/platformio/package/commands/__init__.py b/platformio/package/commands/__init__.py index f38707c9..b0514903 100644 --- a/platformio/package/commands/__init__.py +++ b/platformio/package/commands/__init__.py @@ -11,10 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -import click - - -@click.group("package", short_help="Package manager") -def cli(): - pass diff --git a/platformio/package/commands/pack.py b/platformio/package/commands/pack.py index a617f176..b22d5fcd 100644 --- a/platformio/package/commands/pack.py +++ b/platformio/package/commands/pack.py @@ -16,13 +16,12 @@ import os import click -from platformio.package.commands import cli from platformio.package.manifest.parser import ManifestParserFactory from platformio.package.manifest.schema import ManifestSchema, ManifestValidationError from platformio.package.pack import PackagePacker -@cli.command("pack", short_help="Create a tarball from a package") +@click.command("pack", short_help="Create a tarball from a package") @click.argument( "package", required=True, @@ -32,7 +31,7 @@ from platformio.package.pack import PackagePacker @click.option( "-o", "--output", help="A destination path (folder or a full path to file)" ) -def package_pack(package, output): +def package_pack_cmd(package, output): p = PackagePacker(package) archive_path = p.pack(output) # validate manifest diff --git a/platformio/package/commands/publish.py b/platformio/package/commands/publish.py index a4d6c1f3..d554b2de 100644 --- a/platformio/package/commands/publish.py +++ b/platformio/package/commands/publish.py @@ -23,7 +23,6 @@ from platformio import fs from platformio.clients.account import AccountClient from platformio.clients.registry import RegistryClient from platformio.exception import UserSideException -from platformio.package.commands import cli from platformio.package.manifest.parser import ManifestParserFactory from platformio.package.manifest.schema import ManifestSchema from platformio.package.meta import PackageType @@ -41,7 +40,7 @@ def validate_datetime(ctx, param, value): # pylint: disable=unused-argument return value -@cli.command("publish", short_help="Publish a package to the registry") +@click.command("publish", short_help="Publish a package to the registry") @click.argument( "package", required=True, @@ -69,7 +68,7 @@ def validate_datetime(ctx, param, value): # pylint: disable=unused-argument is_flag=True, help="Do not show interactive prompt", ) -def package_publish( # pylint: disable=too-many-arguments, too-many-locals +def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals package, owner, released_at, private, notify, non_interactive ): click.secho("Preparing a package...", fg="cyan") diff --git a/platformio/package/commands/unpublish.py b/platformio/package/commands/unpublish.py index d28bb964..3185144e 100644 --- a/platformio/package/commands/unpublish.py +++ b/platformio/package/commands/unpublish.py @@ -16,11 +16,10 @@ import click from platformio.clients.account import AccountClient from platformio.clients.registry import RegistryClient -from platformio.package.commands import cli from platformio.package.meta import PackageSpec, PackageType -@cli.command("unpublish", short_help="Remove a pushed package from the registry") +@click.command("unpublish", short_help="Remove a pushed package from the registry") @click.argument( "package", required=True, metavar="[/][@]" ) @@ -35,7 +34,7 @@ from platformio.package.meta import PackageSpec, PackageType is_flag=True, help="Undo a remove, putting a version back into the registry", ) -def package_unpublish(package, type, undo): # pylint: disable=redefined-builtin +def package_unpublish_cmd(package, type, undo): # pylint: disable=redefined-builtin spec = PackageSpec(package) response = RegistryClient().unpublish_package( owner=spec.owner or AccountClient().get_logged_username(),