Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
eb2bb29
Setup initial timeseries group structure from BLOB
krowvin Dec 2, 2025
3885451
Add click options for retrieve
krowvin Dec 2, 2025
d091df2
Regenerate poetry.lock to fix isort checksum
krowvin Dec 5, 2025
d121559
Merge branch 'main' of https://github.com/HydrologicEngineeringCenter…
krowvin Dec 5, 2025
e7b6db4
Merge branch '77-time-series-group-crud' of https://github.com/Hydrol…
krowvin Dec 5, 2025
0ad9fa5
Add logging click option
krowvin Dec 5, 2025
92b0ef2
Add CLI options for retrieve
krowvin Dec 5, 2025
5830697
Add retrieve command
krowvin Dec 5, 2025
35bfc3b
add io utility for writing to disk
krowvin Dec 5, 2025
fc05059
Set default log level
krowvin Dec 5, 2025
7235be9
Remove unused method, allow for stdin or file in
krowvin Dec 5, 2025
3b5de09
Correct types
krowvin Dec 5, 2025
519ad70
Ensure office is uppercase, resolve it in CDA with usace/cwms-data-ap…
krowvin Dec 6, 2025
0e93ca5
Add and test ts group delete command
krowvin Dec 6, 2025
4f093fa
Add smoke test for 3.9 (can't use pytest)
krowvin Dec 10, 2025
a0068b5
Wording on root ts group command
krowvin Dec 10, 2025
7ebf815
First attempt at wrapping cli in an friendly error handler
krowvin Jan 22, 2026
c0341b1
Update black code check version and run formatter for all files
krowvin Feb 3, 2026
ff249de
Merge branch 'main' of https://github.com/HydrologicEngineeringCenter…
krowvin Feb 3, 2026
c89d4b5
Update black dependency version and change code check to use the same…
krowvin Feb 3, 2026
12aa8cc
Disable venv for poetry in CI/CD
krowvin Feb 3, 2026
9d4b7a5
Merge branch 'main' of https://github.com/HydrologicEngineeringCenter…
krowvin Feb 10, 2026
d254ad6
Ensure -h flag is available as well as --help
krowvin Feb 10, 2026
793b945
Update poetry lock to latest
krowvin Feb 10, 2026
3cb7611
Merge branch '101-handle-missing-system-certs-error' of https://githu…
krowvin Feb 10, 2026
0fd873a
Merge branch 'main' of https://github.com/HydrologicEngineeringCenter…
krowvin Feb 12, 2026
cb3d957
Remove TS Group command
krowvin Feb 12, 2026
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
2 changes: 1 addition & 1 deletion cwmscli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from cwmscli.utils.ssl_errors import is_cert_verify_error, ssl_help_text


@click.group()
@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep typing -h instead of --help 👍

def cli():
pass

Expand Down
5 changes: 1 addition & 4 deletions cwmscli/commands/commands_cwms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cwmscli import requirements as reqs
from cwmscli.callbacks import csv_to_list
from cwmscli.commands import csv2cwms
from cwmscli.utils import api_key_loc_option, common_api_options
from cwmscli.utils import api_key_loc_option, common_api_options, to_uppercase
from cwmscli.utils.deps import requires


Expand Down Expand Up @@ -251,6 +251,3 @@ def list_cmd(**kwargs):
from cwmscli.commands.blob import list_cmd

list_cmd(**kwargs)


# endregion
25 changes: 25 additions & 0 deletions cwmscli/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

import click


Expand All @@ -7,6 +9,16 @@ def to_uppercase(ctx, param, value):
return value.upper()


def _set_log_level(ctx, param, value):
if value is None:
return
level = getattr(logging, value.upper(), None)
if level is None:
raise click.BadParameter(f"Invalid log level: {value}")
logging.getLogger().setLevel(level)
return value


office_option = click.option(
"-o",
"--office",
Expand Down Expand Up @@ -47,6 +59,18 @@ def to_uppercase(ctx, param, value):
type=str,
help="file storing Api Key. One of api-key or api-key-loc are required",
)
log_level_option = click.option(
"--log-level",
type=click.Choice(
["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], case_sensitive=False
),
default="INFO",
envvar="LOG_LEVEL",
callback=_set_log_level,
expose_value=False, # Callback will set the log level of all methods
is_eager=True, # Run before other commands (to cover any logging statements)
help="Set logging verbosity (overrides default INFO).",
)


def get_api_key(api_key: str, api_key_loc: str) -> str:
Expand All @@ -62,6 +86,7 @@ def get_api_key(api_key: str, api_key_loc: str) -> str:


def common_api_options(f):
f = log_level_option(f)
f = office_option(f)
f = api_root_option(f)
f = api_key_option(f)
Expand Down
16 changes: 16 additions & 0 deletions cwmscli/utils/io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import logging
import os
from pathlib import Path


def write_to_file(file_path: str, data: str, create_dir: bool = False) -> None:
"""Writes data to a file at the specified path."""
if not file_path:
raise ValueError("You must specify a file path to write data to.")
if not data:
raise ValueError("No data provided to write to file.")
if create_dir:
Path(os.path.dirname(file_path)).mkdir(parents=True, exist_ok=True)
with open(file_path, "w") as file:
file.write(data)
logging.info(f"Data written to file: {file_path}")
Loading