Skip to content

Commit 7561b2f

Browse files
committed
refactor(config): use store_const + mutually exclusive group for log-upload flags
--upload-logs and --no-upload-logs now share dest='upload_logs' via store_const (True/False) in an argparse mutually exclusive group. argparse handles the conflict natively; drop the manual mutex check and the tri-state mapping in from_args. args.upload_logs is now Optional[bool] directly. The undocumented --upload_logs / --no_upload_logs snake_case aliases are dropped (introduced earlier in this same unreleased branch; no users to break).
1 parent d630013 commit 7561b2f

1 file changed

Lines changed: 9 additions & 24 deletions

File tree

socketsecurity/config.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,6 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
215215

216216
args = parser.parse_args(args_list)
217217

218-
if args.upload_logs and args.decline_logs:
219-
parser.error("--upload-logs and --no-upload-logs are mutually exclusive")
220-
upload_logs: Optional[bool] = (
221-
True if args.upload_logs else False if args.decline_logs else None
222-
)
223-
224218
if args.reach_exclude_paths:
225219
logging.warning(
226220
"--reach-exclude-paths is deprecated; use --exclude-paths instead. "
@@ -291,7 +285,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
291285
'ignore_commit_files': args.ignore_commit_files,
292286
'disable_blocking': args.disable_blocking,
293287
'disable_ignore': args.disable_ignore,
294-
'upload_logs': upload_logs,
288+
'upload_logs': args.upload_logs,
295289
'strict_blocking': args.strict_blocking,
296290
'integration_type': args.integration,
297291
'pending_head': args.pending_head,
@@ -876,35 +870,26 @@ def create_argument_parser() -> argparse.ArgumentParser:
876870
action="store_true",
877871
help=argparse.SUPPRESS
878872
)
879-
advanced_group.add_argument(
873+
log_upload_group = advanced_group.add_mutually_exclusive_group()
874+
log_upload_group.add_argument(
880875
"--upload-logs",
881876
dest="upload_logs",
882-
action="store_true",
877+
action="store_const",
878+
const=True,
883879
help="Upload the CLI's log output to the Socket backend for this run. "
884880
"When set, the CLI registers the run with share_logs=true and streams "
885881
"its log records in 5s batches. Default off. Mutually exclusive with "
886882
"--no-upload-logs."
887883
)
888-
advanced_group.add_argument(
889-
"--upload_logs",
890-
dest="upload_logs",
891-
action="store_true",
892-
help=argparse.SUPPRESS
893-
)
894-
advanced_group.add_argument(
884+
log_upload_group.add_argument(
895885
"--no-upload-logs",
896-
dest="decline_logs",
897-
action="store_true",
886+
dest="upload_logs",
887+
action="store_const",
888+
const=False,
898889
help="Explicitly opt out of uploading CLI logs to the Socket backend, even "
899890
"when an org-level override would otherwise enable it. Mutually "
900891
"exclusive with --upload-logs."
901892
)
902-
advanced_group.add_argument(
903-
"--no_upload_logs",
904-
dest="decline_logs",
905-
action="store_true",
906-
help=argparse.SUPPRESS
907-
)
908893
advanced_group.add_argument(
909894
"--strict-blocking",
910895
dest="strict_blocking",

0 commit comments

Comments
 (0)