fix(securefile): reject a file ID argument combined with --id or --name

What does this MR do and why?

securefile remove ignores its positional ID argument when --id or --name is also given, and deletes the file the flag points at. For a delete command, acting on a different file than the one named on the command line is dangerous:

$ glab securefile remove 1 --id 2 -y
# deletes secure file 2, not 1
DELETE .../secure_files/2

complete returns as soon as --name or --id is set and never reads args:

if name != "" {
	o.fileName = name
	return nil
}
if cmd.Flags().Changed("id") {
	o.fileID, err = cmd.Flags().GetInt64("id")
} else {
	o.fileID, err = strconv.ParseInt(args[0], 10, 64)
}

--id and --name are already guarded with MarkFlagsMutuallyExclusive, but the positional argument was left out of that guard. This MR rejects the combination at the top of complete, so the conflict is reported instead of silently resolved.

Test coverage

Two table cases: a positional ID with --id, and a positional ID with --name, both expecting the error and no API call. On the unfixed code the first would issue RemoveSecureFile(2).

go test ./internal/commands/securefile/remove/ is green.

Closes #8430 (closed)

Merge request reports

Loading
Loading