Last active
August 17, 2022 19:13
-
-
Save zachdaniel/947bda4a8866725b5f5d118f237563b1 to your computer and use it in GitHub Desktop.
Soource Manipulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code_change = | |
CodeChange.new() # just one potential idea for what the multi-file tracking would be called | |
|> CodeChange.create_file(path, initial_contents) | |
|> CodeChange.update_file(path, [ | |
Operation.add_defmodule(module_name), | |
Operation.add_use_to_module(module_name, thing_it_uses), | |
MyCustomOperations.do_my_special_thing(...) | |
], instructions_on_failure: "Add x to your module.") | |
# I need this for my use case because individual code changes may depend on the current state of other files | |
# As I'm building I have access to all of the code through the lens of any changes so far. i.e | |
# will read the file on disk or if its been modified will show me that | |
CodeChange.read_file(code_change, path) | |
# I can pick back up after looking at the current state | |
code_change = | |
code_change | |
|> CodeChange.update_file(path, [...]) | |
# It can be applied as a dry run | |
CodeChange.apply(code_change, dry_run?: true) | |
# Or it can just be applied | |
CodeChange.apply(code_change) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment