Skip to content

Add --content-only and --rename-only scope flags#47

Open
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:feat/scope-flags-issue-36
Open

Add --content-only and --rename-only scope flags#47
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:feat/scope-flags-issue-36

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • Add --content-only and --rename-only flags (mutually exclusive)
  • Default behavior unchanged: rewrite contents and rename paths
  • Document scope flags in README
  • Tests cover default, content-only, rename-only, and both-flags error

Fixes #36

Made with Cursor

Parse mutually exclusive flags before FIND/REPLACE args. Default behavior
rewrites contents and renames paths; each flag limits the operation to one
half. README and tests cover all three modes and the both-flags error.

Fixes dolph#36

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc3a1e489a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread find_replace.go
Comment on lines +40 to +53
for i < len(args) && strings.HasPrefix(args[i], "-") {
switch args[i] {
case "--content-only":
if scope != scopeAll {
return findReplace{}, fmt.Errorf("cannot pass both --content-only and --rename-only")
}
scope = scopeContentOnly
case "--rename-only":
if scope != scopeAll {
return findReplace{}, fmt.Errorf("cannot pass both --content-only and --rename-only")
}
scope = scopeRenameOnly
default:
return findReplace{}, fmt.Errorf("unknown flag: %s", args[i])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow FIND values that start with '-'

The new argument parser treats every leading dash-prefixed token as a flag and returns unknown flag for anything except the two scope switches, so valid search terms like -foo can no longer be used as FIND (and -- is also rejected). This is a CLI regression from the previous behavior, which accepted any two positional strings; please support an end-of-flags terminator or stop flag parsing once a non-scope token is encountered.

Useful? React with 👍 / 👎.

Comment thread find_replace.go
Comment on lines 66 to +70
func main() {
// Remove date/time from logging output
log.SetFlags(0)
rand.Seed(time.Now().UnixNano())

if len(os.Args) != 3 {
log.Fatal("Usage: find-replace FIND REPLACE")
fr, err := parseArgs(os.Args[1:])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore non-deterministic seeding for temp-name RNG

This change removed startup seeding of math/rand, but File.Write still uses RandomString for temporary file names. Because go.mod targets Go 1.19, the default global RNG stream is deterministic unless seeded, so separate runs can reuse the same temp-name sequence in a directory, increasing cross-run collisions/overwrite races during concurrent use. Reintroduce explicit seeding (or switch temp-name generation to a non-deterministic source).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --rename-only and --content-only scope flags

1 participant