#lang racket/base

; Remove a user from the database

(require
  "src/notepad/user.rkt"
  "src/pages/notepad.rkt" ; To open the database
  )

(displayln "Removing a user.")
; Ask for user name
(displayln "Enter the user name:")
(define name (read-line))
(when (eof-object? name)
  (exit 1))

; Get user
(define usr (get-user-by-name name))
(cond
  (usr
    (remove-user usr)
    (displayln (string-append "User " name " removed.")))
  (#t
    (displayln (string-append "User " name " does not exists!"))
    (exit 2)))
