feat(user): report on another user's time entries
- Add user_id parameter to fetch_issues_with_spent_time(). - Support numeric ID, login, or full name resolution. - Reject ambiguous names and unknown users with clear messages. - Add CLI flags: --user-id, --user-login, --user-name. - Only allow one user flag at a time. - Add ResourceNotFoundError handling. - Update README with usage examples. - Add tests for user resolution and CLI flags. Closes #40
This commit is contained in:
@@ -76,8 +76,29 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
action="store_true",
|
||||
help="Print summary (total hours by project/version) to stderr",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--user-id",
|
||||
help="Redmine user ID for the report (default: current user)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--user-login",
|
||||
help="Redmine user login for the report (alternative to --user-id)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--user-name",
|
||||
help="Redmine user full name for the report (alternative to --user-id; ambiguous names are rejected)",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
# Валидация взаимоисключающих флагов пользователя
|
||||
user_args = [args.user_id, args.user_login, args.user_name]
|
||||
if sum(bool(a) for a in user_args) > 1:
|
||||
print(
|
||||
"❌ Specify only one of --user-id, --user-login, or --user-name.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
# CLI-переопределения имеют приоритет над .env/env.
|
||||
if args.config:
|
||||
Config.load_config(args.config)
|
||||
@@ -105,7 +126,11 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
return 1
|
||||
|
||||
try:
|
||||
issue_hours = fetch_issues_with_spent_time(from_date, to_date)
|
||||
issue_hours = fetch_issues_with_spent_time(
|
||||
from_date,
|
||||
to_date,
|
||||
user_id=args.user_id or args.user_login or args.user_name,
|
||||
)
|
||||
except RedmineAPIError as e:
|
||||
print(f"❌ {e.message}", file=sys.stderr)
|
||||
if args.debug and e.original is not None:
|
||||
|
||||
Reference in New Issue
Block a user