Rename "package" command to "pkg"

This commit is contained in:
Ivan Kravets
2022-02-11 22:24:37 +02:00
parent 83d115acca
commit 4982676ca8
6 changed files with 29 additions and 21 deletions

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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="[<organization>/]<pkgname>[@<version>]"
)
@ -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(),