-- | Configuration of fields from
--   field names given as singleton string types
--   For example in the `Parser "myField" MyType
--   @myField@ is used to create an option name like @--my-field@ (by default)
module Data.Registry.Options.FieldConfiguration where

import Data.Registry.Options.Text
import qualified Data.Text as T
import Protolude
import qualified Prelude

-- | These options are used at runtime to take a field name and build its short/long name + metavar
data FieldConfiguration = FieldConfiguration
  { -- | make a short name from a field name. For example @"force" -> \'f\'@
    FieldConfiguration -> Text -> Char
makeShortName :: Text -> Char,
    -- | make a long name from a field name. For example @"forceCopy" -> 'force-copy'@
    FieldConfiguration -> Text -> Text
makeLongName :: Text -> Text,
    -- | describe the type of a field from its name. For example @"sourceFile" -> "File"@
    FieldConfiguration -> Text -> Text
makeMetavar :: Text -> Text
  }

-- | The default options are taking a Package1.Package2.camelCase name and
--    - creating a short name = "c"
--    - creating a long name = "camel-case"
--    - creating a metavar = "CAMELCASE"
defaultFieldConfiguration :: FieldConfiguration
defaultFieldConfiguration :: FieldConfiguration
defaultFieldConfiguration =
  (Text -> Char)
-> (Text -> Text) -> (Text -> Text) -> FieldConfiguration
FieldConfiguration (forall a. [a] -> a
Prelude.head forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. ConvertText a b => a -> b
toS forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
dropQualifier) (Text -> Text
camelCaseToHyphenated forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
dropQualifier) (Text -> Text
T.toUpper forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
dropQualifier)