Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version command #127

Merged
merged 4 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion stactools_cli/stactools/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
def register_plugin(registry):
# Register subcommands

from stactools.cli.commands import (copy, info, layout, merge, migrate)
from stactools.cli.commands import (copy, info, layout, merge, migrate,
version)

registry.register_subcommand(copy.create_copy_command)
registry.register_subcommand(copy.create_move_assets_command)
registry.register_subcommand(info.create_info_command)
registry.register_subcommand(info.create_describe_command)
registry.register_subcommand(layout.create_layout_command)
registry.register_subcommand(merge.create_merge_command)
registry.register_subcommand(version.create_version_command)

# TODO
# registry.register_subcommand(migrate.create_migrate_command)
Expand Down
14 changes: 14 additions & 0 deletions stactools_cli/stactools/cli/commands/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from click import echo
from pystac.version import get_stac_version
from stactools.core.version import __version__


def create_version_command(cli):
gadomski marked this conversation as resolved.
Show resolved Hide resolved
@cli.command('version', short_help='Display version info.')
def version_command():
"""Display version info
"""
echo(f"stactools version {__version__}")
echo(f"PySTAC version {get_stac_version()}")

return version_command
17 changes: 17 additions & 0 deletions tests/cli/commands/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pystac.version import get_stac_version
from stactools.core.version import __version__
from stactools.cli.commands.version import create_version_command

from tests.utils import CliTestCase


class VersionTest(CliTestCase):
def create_subcommand_functions(self):
return [create_version_command]

def test_hello_world(self):
result = self.run_command(['version'])
self.assertEqual(0, result.exit_code)
expected = (f"stactools version {__version__}\n"
f"PySTAC version {get_stac_version()}\n")
self.assertEqual(expected, result.output)