-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from jan-rycko/master
package_versions_command.
- Loading branch information
Showing
5 changed files
with
49 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from commands.publish_command import get_api_key | ||
from packages.api_client import ApiClient | ||
from packages.package_utils import get_package_versions | ||
|
||
def common_format(s: str): | ||
return s.strip().lower() | ||
|
||
|
||
def package_versions_command(args): | ||
package = args.package | ||
|
||
repository = args.repository | ||
|
||
api_key = get_api_key(args) | ||
api_client = ApiClient(repository, api_key) | ||
|
||
response_json = api_client.get_package_info(package) | ||
|
||
versions = get_package_versions(response_json) | ||
|
||
for version in versions: | ||
print(version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from commands.publish_command import publish_command | ||
from commands.version_check_command import version_check_command | ||
from commands.package_version_command import package_version_command | ||
from commands.package_versions_command import package_versions_command | ||
from error_handling.exceptions import ZipperoClientException | ||
from utils.constants import api_key_environment_variable | ||
from commands.version_check_command import up_to_date_string, outdated_string | ||
|
@@ -53,6 +54,12 @@ def configure_argparser() -> argparse.ArgumentParser: | |
package_version_parser.add_argument('--repository', '-r', type=str, help='url to target repository') | ||
package_version_parser.add_argument('--key', '-k', type=str, help=f'api key to use if not provided will use {api_key_environment_variable}') | ||
|
||
package_versions_parser = subparsers.add_parser('package-versions', help=f'checks package latest version.') | ||
package_versions_parser.set_defaults(handler=package_versions_command) | ||
package_versions_parser.add_argument('package', type=str, help='name of package') | ||
package_versions_parser.add_argument('--repository', '-r', type=str, help='url to target repository') | ||
package_versions_parser.add_argument('--key', '-k', type=str, help=f'api key to use if not provided will use {api_key_environment_variable}') | ||
|
||
install_parser = subparsers.add_parser('prefetch', help='prefetches package to local cache') | ||
install_parser.set_defaults(handler=prefetch_command) | ||
install_parser.add_argument('package', type=str, help='name of package or name@version e.g. [email protected]') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters