{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module KitsuneBook.Types where

import BasicPrelude
import Control.Error
import Control.Monad.Trans.Reader
import KitsuneBook.Settings

type KitsuneBook a = ReaderT Args (EitherT Text IO) a

askDomain :: KitsuneBook Domain
askDomain = asks argDomain

askSettingsPath :: KitsuneBook Text
askSettingsPath = asks argSettingsPath

askSettings :: KitsuneBook Settings
askSettings = asks argSettings

data Args = Args {argDomain :: Domain
                 ,argSettingsPath :: Text
                 ,argSettings :: Settings}

data CommandTarget
  = TargetNote Int
  | TargetNoteInfo Int
  | TargetNoteAssets Int
  | TargetNoteRoot Int
  | TargetSettings
  deriving (Show)

data ProgArgs =
  ProgArgs Text
           Domain
           Command
  deriving (Show)

data NoteInfo =
  NoteInfo {noteName :: Text
           ,noteTags :: [Text]
           ,noteDescription :: Text
           ,noteExtension :: Text}
  deriving (Show)

-- Domain

data Domain
  = DomainMain
  | DomainArchive
  | DomainTrash

instance Show Domain where
  showsPrec _ DomainMain = showString "Main domain"
  showsPrec _ DomainArchive = showString "Archive domain"
  showsPrec _ DomainTrash = showString "Trash domain"

data Command
  = CommandVersion
  | CommandDoctor
  | CommandView CommandTarget
  | CommandEdit CommandTarget
  | CommandPath CommandTarget
  | CommandList ListType
  | CommandSearch [Text]
  | CommandMove Int
                Domain
  | CommandRemove Int
  | CommandArchive Int
  | CommandRestore Int
  | CommandCreate [Text]
  | CommandChangeExtension Int
                           Text
  | CommandClear
  deriving (Show)
