Skip to content

Commit

Permalink
Add okdata -e and okdata -v
Browse files Browse the repository at this point in the history
Add new commands `okdata -e` and `okdata -v` for printing the current
environment and the current version of okdata-cli, respectively.
  • Loading branch information
simenheg committed Jun 13, 2024
1 parent 94cd110 commit e62ac7f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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

0 comments on commit e62ac7f

Please sign in to comment.