Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Add a tool in a branch #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .lift/config.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
customTools = [ ".lift/markdown_tool.py" ]
customTools = [ ".lift/markdown_tool.py", ".lift/tool_added_in_branch.py" ]
70 changes: 70 additions & 0 deletions .lift/tool_added_in_branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python3

import argparse
import json
import os
from pathlib import Path

def emit_version():
print(1)


def emit_name():
print("tool_added_in_branch")


def emit_applicable():
print("true")

def run(path):
pathlist = Path(path).glob('**/*.md')

tool_notes = []
for filename in pathlist:
tool_notes.extend(process_file(filename))

print(json.dumps(tool_notes))

def process_file(filename):
file_display = str(filename)
tool_notes = []
with open(filename, 'r') as f:
current_line = 0
for line in f:
current_line += 1
if("branch tool" in line):
tool_notes.append(line_to_tool_note(file_display, current_line, "Did you mean an axe?"))

return tool_notes

def line_to_tool_note(filename, line_number, message):
return {
"type": "Tool Added In Branch",
"message": message,
"file": filename,
"line": line_number
}

def main():
parser = argparse.ArgumentParser(description='Tool Added In Branch')
parser.add_argument('path', metavar='PATH', help='Path to code')
parser.add_argument('commit_hash', metavar='HASH', help='Commit hash')
parser.add_argument('command', metavar='COMMAND', help='Command')

args = parser.parse_args()

path = args.path

command = args.command

if command == "version":
emit_version()
elif command == "name":
emit_name()
elif command == "applicable":
emit_applicable()
elif command == "run":
run(path)

if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions documentation/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Here is where I would add some documentation if this were a real project. Alas,
## Documentation Subsection

I :purple_heart: markdown

Test out the branch tool

Choose a reason for hiding this comment

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

Tool Added In Branch: Did you mean an axe?
(at-me in a reply with help or ignore)