Overwrite ability#106
Conversation
palkan
left a comment
There was a problem hiding this comment.
Thanks!
The implementation looks good to me; let's figure out the tests.
Also:
--overwrite ability will work only with --single-version argument
Can we display a warning if --overwrite is specified but --single-version is missing?
|
|
||
| ## master | ||
|
|
||
| ## 0.15.4 (2023-01-05) |
There was a problem hiding this comment.
We do not update versions in PRs
There was a problem hiding this comment.
moved to ##master
| -o, --output=OUTPUT Specify output directory or file or stdout | ||
| --min-version=VERSION Specify the minimum Ruby version to support | ||
| --single-version Only create one version of a file (for the earliest Ruby version) | ||
| --overwrite Overwrites the original file with one version of --single-version (Works with --single-version) |
There was a problem hiding this comment.
| --overwrite Overwrites the original file with one version of --single-version (Works with --single-version) | |
| --overwrite Overwrites the original file with one version of --single-version (works only with --single-version) |
There was a problem hiding this comment.
changed to
**works only with --single-version or --rewrite**
| end | ||
|
|
||
| def overwrite_original_file? | ||
| single_version && overwrite_original_file |
There was a problem hiding this comment.
We can remove single_version from here, since we explicitly check for it presence after parsing
| single_version && overwrite_original_file | |
| overwrite_original_file |
| exit 2 | ||
| end | ||
|
|
||
| if @overwrite_original_file && !@single_version |
There was a problem hiding this comment.
I think, we should use single_version? here and also mention --rewriters (as an alternative to --single-version) in the message:
| if @overwrite_original_file && !@single_version | |
| if overwrite_original_file? && !single_version? |
There was a problem hiding this comment.
thanks!
done
Also added spec test for --overwrite and --rewrite args
…s. Add spec overwrite_original_file with --rewrite
|
Hello @palkan |
…ngPatternError, so we need load -ruby-next)
palkan
left a comment
There was a problem hiding this comment.
Thanks for your help!
I'll merge this and apply changes myself.
| old_content = File.read(File.join(__dir__, "dummy", "transpile_me.rb")) | ||
| File.write(File.join(__dir__, "dummy", "overwrite", "transpile_me.rb"), old_content) |
There was a problem hiding this comment.
We can prepare a fixture in the before hook instead of restoring it in the after hook. This way, we can avoid duplicating the transpile_me.rb file.
| end | ||
|
|
||
| if overwrite_original_file? && !single_version? | ||
| $stdout.puts "--single-version and --rewrite are missing, --overwrite arg works only with --single-version or --rewrite" |
There was a problem hiding this comment.
The phrase "--single-version and --rewrite are missing" is confusing; it sounds like we need both
Hello, @palkan!
Please, review my changes
What is the purpose of this pull request?
Support passing --overwrite to CLI for overwriting the original_file
What changes did you make? (overview)
Add the ability to parse --overwrite
Is there anything you'd like reviewers to focus on?
--overwriteability will work only with--single-versionargument. Without the argument--single-versionoverwrite mode will ignoredChecklist
Closes #104