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

Add okdata -e and okdata -v #225

Merged
merged 1 commit into from
Jun 14, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## ?.?.? - Unreleased

* New commands `okdata -e` and `okdata -v` for printing the current environment
and the current version of okdata-cli, respectively.

## 4.1.0 - 2024-04-22

* The minimum required version of `okdata-sdk` is now 3.1.1. This ensures
Expand Down
8 changes: 7 additions & 1 deletion okdata/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@

def main():
argv = sys.argv
if len(argv) < 2 or argv[1] == "help":
if len(argv) < 2:
BaseCommand().help()
return
if argv[1] in ("-e", "--environment"):
BaseCommand().print_env()
return
if argv[1] in ("-v", "--version"):
BaseCommand().print_version()
return

command = get_command_class(argv)

Expand Down
8 changes: 8 additions & 0 deletions okdata/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class BaseCommand:
okdata pubs [options]
okdata status [options]
okdata teams [options]
okdata -e | --environment
okdata -h | --help
okdata -v | --version

Commands available:
datasets
Expand Down Expand Up @@ -119,6 +121,12 @@ def no_data(self, str):
def help(self):
print(self.__doc__, end="")

def print_env(self):
print(self.sdk.config.resolve_environment(None))

def print_version(self):
print(self.version)

def print_error_response(self, response_body):
if not isinstance(response_body, dict):
print(response_body)
Expand Down
Loading