Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swept.py #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions swept.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ def display_diff(repo: Repo) -> None:

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Edit a section of code, PR with changes.')
parser.add_argument('-f', '--file', help='location of a file', required=True)
parser.add_argument('-f', '--file', help='location of a file', required=True, type=Path)
parser.add_argument('-i', '--instruction', help='instruction on how to edit the file', type=str, required=True)
parser.add_argument('-r', '--repo', help='location to git repo', type=str, default='./')
parser.add_argument('-r', '--repo', help='location to git repo', type=Path, default='./')
parser.add_argument('-d', '--diff', help='show diff', action='store_true')
parser.add_argument('-pr', '--pull-request', help='add change, commit, push and raise a PR', action='store_true')
args = parser.parse_args()

file = Path(args.file)
repo_loc = Path(args.repo)
file = args.file
repo_loc = args.repo
instruction = args.instruction.strip()
repo = Repo(repo_loc)

assert file.exists() and file.is_file(), "File does not exist!"
assert file.suffix in ALLOWED_FILE_EXT, "Filetype not supported"
assert file.is_file(), f"{file} does not exist or is not a file"
assert file.suffix in ALLOWED_FILE_EXT, f"Filetype {file.suffix} not supported"
assert len(instruction) > 0, "Instruction not valid"
assert not repo.bare, "Repo is bare!"

Expand Down