Sunday, 26 October 2025
Production team software
#!/usr/bin/env ruby
require 'json'
# File to store tasks
TASK_FILE = 'tasks.json'
# Load existing tasks or initialize empty array
def load_tasks
if File.exist?(TASK_FILE)
JSON.parse(File.read(TASK_FILE))
else
[]
end
end
# Save tasks to file
def save_tasks(tasks)
File.write(TASK_FILE, JSON.pretty_generate(tasks))
end
# Display menu
def display_menu
puts "\nAI Annotator Productivity Tool"
puts "1. View Tasks"
puts "2. Add Task"
puts "3. Complete Task"
puts "4. Exit"
print "Choose an option: "
end
# List all tasks
def list_tasks(tasks)
if tasks.empty?
puts "No tasks found."
else
puts "\nYour Tasks:"
tasks.each_with_index do |task, index|
status = task['completed'] ? '✓' : ' '
puts "#{index + 1}. [#{status}] #{task['description']}"
end
end
end
# Add new task
def add_task(tasks)
print "Enter task description: "
desc = gets.chomp
tasks << { 'description' => desc, 'completed' => false }
save_tasks(tasks)
puts "Task added."
end
# Mark task as completed
def complete_task(tasks)
list_tasks(tasks)
print "Enter task number to mark as completed: "
index = gets.chomp.to_i - 1
if index >= 0 && index < tasks.size
tasks[index]['completed'] = true
save_tasks(tasks)
puts "Task marked as completed."
else
puts "Invalid task number."
end
end
# Main program loop
tasks = load_tasks
loop do
display_menu
choice = gets.chomp
case choice
when '1'
list_tasks(tasks)
when '2'
add_task(tasks)
when '3'
complete_task(tasks)
when '4'
puts "Goodbye!"
break
else
puts "Invalid option. Please try again."
end
end
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment