Skip to content
Merged
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
26 changes: 26 additions & 0 deletions tavern/tomes/file_write/main.eldritch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

def main():
new_file_path = input_params['path']
new_file_parent_dir = file.parent_dir(new_file_path)
new_file_content = input_params['content']

# if file parent directory does not exist, error and exit.
if not file.exists(new_file_parent_dir):
eprint(f"[ERROR] Parent Directory for File does not exist at path: '{new_file_path}'.")
eprint(f"[ERROR] Exiting...")
return

# if file exists, remove it.
if file.exists(new_file_path):
print("[INFO] File was detected at the path before write. Trying to remove the file...")
file.remove(new_file_path)
print("[INFO] File was successfully removed!")

# if unable to write to destination will error
file.write(new_file_path, new_file_content)

# Print a Success!
print(f"[INFO] The file '{new_file_path}' was successfully written!")


main()
14 changes: 14 additions & 0 deletions tavern/tomes/file_write/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Write File
description: Write the given utf-8 content to a file
author: cictrone
support_model: FIRST_PARTY
tactic: EXECUTION
paramdefs:
- name: path
type: string
label: File path
placeholder: "/tmp/cat.txt"
- name: content
type: string
label: Content to write
placeholder: "meow"