From 4a21b9f2cd215292da25dad3aa7e6079e4ad2ff1 Mon Sep 17 00:00:00 2001 From: Ravi Ranjan Date: Sat, 7 Mar 2026 15:25:51 +0530 Subject: [PATCH 1/2] FIX: Enable version command without login and redirect errors to stderr #28 --- cbrain_cli/main.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/cbrain_cli/main.py b/cbrain_cli/main.py index 41e2d07..d38b073 100644 --- a/cbrain_cli/main.py +++ b/cbrain_cli/main.py @@ -399,23 +399,20 @@ def main(): # MARK: Setup CLI args = parser.parse_args() + if args.command == "version": + return handle_errors(version_info)(args) if not args.command: - parser.print_help() - return - + parser.print_help(file=sys.stderr) + return 1 + # Handle session commands (no authentication needed for login, version, and whoami). if args.command == "login": return handle_errors(create_session)(args) - elif args.command == "version": - return handle_errors(version_info)(args) + elif args.command == "whoami": return handle_errors(whoami_user)(args) - # All other commands require authentication. - if not is_authenticated(): - return 1 - # Handle authenticated commands. if args.command == "logout": return handle_errors(logout_session)(args) @@ -433,23 +430,23 @@ def main(): if not hasattr(args, "action") or not args.action: # Show help for the specific model command. if args.command == "file": - file_parser.print_help() + file_parser.print_help(file=sys.stderr) elif args.command == "dataprovider": - dataprovider_parser.print_help() + dataprovider_parser.print_help(file=sys.stderr) elif args.command == "project": - project_parser.print_help() + project_parser.print_help(file=sys.stderr) elif args.command == "tool": - tool_parser.print_help() + tool_parser.print_help(file=sys.stderr) elif args.command == "tool-config": - tool_configs_parser.print_help() + tool_configs_parser.print_help(file=sys.stderr) elif args.command == "tag": - tag_parser.print_help() + tag_parser.print_help(file=sys.stderr) elif args.command == "background": - background_parser.print_help() + background_parser.print_help(file=sys.stderr) elif args.command == "task": - task_parser.print_help() + task_parser.print_help(file=sys.stderr) elif args.command == "remote-resource": - remote_resource_parser.print_help() + remote_resource_parser.print_help(file=sys.stderr) return 1 else: # Execute the function associated with the command. From e45acb66c978c00cab24a1c98b916a31b2b280a0 Mon Sep 17 00:00:00 2001 From: Ravi Ranjan Date: Sat, 7 Mar 2026 15:34:27 +0530 Subject: [PATCH 2/2] FIX: Allow version without login, redirect errors to stderr, and add default upload type #28 --- cbrain_cli/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cbrain_cli/main.py b/cbrain_cli/main.py index d38b073..4236f08 100644 --- a/cbrain_cli/main.py +++ b/cbrain_cli/main.py @@ -111,6 +111,7 @@ def main(): "--data-provider", type=int, required=True, help="Data provider ID" ) file_upload_parser.add_argument("--group-id", type=int, help="Group ID") + file_upload_parser.add_argument("--file-type", type=str, default="SingleFile", help="File type (default: SingleFile)") file_upload_parser.set_defaults(func=handle_errors(handle_file_upload))