Skip to content

Treat trailing whitespace and comment delimiters as part of the selfup prefix#401

Merged
kachick merged 4 commits intomainfrom
regex-cut
Oct 12, 2025
Merged

Treat trailing whitespace and comment delimiters as part of the selfup prefix#401
kachick merged 4 commits intomainfrom
regex-cut

Conversation

@kachick
Copy link
Copy Markdown
Owner

@kachick kachick commented Oct 11, 2025

Resolves #398

Comment thread cmd/selfup/main.go
const usage = `Usage: selfup [SUB] [OPTIONS] [PATH]...

$ selfup run .github/workflows/*.yml
$ selfup run --prefix='# Update with this json: ' --skip-by='nix run' .github/workflows/*.yml
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This PR removes all known use cases for changing the default prefix.
I will keep the feature for now but remove its usage instructions from the help flag.

Comment thread cmd/selfup/main.go
$ selfup run .github/workflows/*.yml
$ selfup run --prefix='# Update with this json: ' --skip-by='nix run' .github/workflows/*.yml
$ selfup list .github/workflows/*.yml
$ selfup migrate .github/workflows/have_beta_schema.yml
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Not related to this PR, however I think this migration feature is now needless for users.

Comment thread cmd/selfup/main.go

prefix, err := regexp.Compile(prefixStr)
if err != nil {
log.Fatalf("Given an invalid regex: `%v`", err)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

For example:

> go run ./cmd/selfup list -prefix='\d(' -check --skip-by=do_not_update_this_file examples/simple.txt
2025/10/12 16:17:44 Given an invalid regex: `error parsing regexp: missing closing ): `\d(``
exit status 1

@kachick kachick changed the title Relax default prefix Treat trailing whitespace and comment delimiters as part of the selfup prefix Oct 12, 2025
@kachick kachick marked this pull request as ready for review October 12, 2025 07:23
@kachick kachick merged commit 9e4309a into main Oct 12, 2025
9 checks passed
@kachick kachick deleted the regex-cut branch October 12, 2025 07:24
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.

Comment is getting removed

1 participant