Skip to content

Commit

Permalink
Merge pull request #4 from trizmark/skip-authentication-for---version
Browse files Browse the repository at this point in the history
Skip authentication for --version
  • Loading branch information
trizmark authored Jun 4, 2024
2 parents 29e4d1f + 31eb85f commit ee151cc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pymyenergi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@


async def main(args):
# handle --version first; no need to authenticate for this
if args.version:
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
version_file = open(os.path.join(ROOT_DIR, "VERSION"))
version = version_file.read().strip()
print(version)
sys.exit(0)
username = args.username or input("Please enter your hub serial number: ")
password = args.password or getpass(prompt="Password (apikey): ")
if not args.skip_oauth:
Expand All @@ -44,12 +51,6 @@ async def main(args):
logging.root.setLevel(logging.DEBUG)
client = MyenergiClient(conn)
try:
if args.version:
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
version_file = open(os.path.join(ROOT_DIR, "VERSION"))
version = version_file.read().strip()
print(version)
sys.exit(0)
if args.command == "list":
devices = await client.get_devices(args.kind)
for device in devices:
Expand Down

0 comments on commit ee151cc

Please sign in to comment.