-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy0.py
More file actions
25 lines (20 loc) · 827 Bytes
/
copy0.py
File metadata and controls
25 lines (20 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import argparse
import pyperclip
# Set up argument parsing
parser = argparse.ArgumentParser(description='Copy file content to clipboard')
parser.add_argument('file_path', nargs='?', help='Path to the file')
parser.add_argument('--verbosity', type=str, choices=['no', 'aggressive'], default='no', help='Verbosity level')
args = parser.parse_args()
def copy_file_content(file_path, verbosity='no'):
# Read the file content
with open(file_path, 'r') as file:
content = file.read()
if verbosity == 'aggressive':
print(f"Copying content of {file_path} to clipboard.")
# Copy the file content to the clipboard
pyperclip.copy(content)
if __name__ == '__main__':
if args.file_path:
copy_file_content(args.file_path, args.verbosity)
else:
print("No file path provided.")