Parse module name into List in CLI options parser helper.

This commit is contained in:
Dillon Kearns 2023-02-06 14:17:28 -08:00
parent 17ed841d4b
commit 57a3ecf13f
2 changed files with 9 additions and 4 deletions

View File

@ -30,7 +30,7 @@ import Pages.Script as Script exposing (Script)
type alias CliOptions = type alias CliOptions =
{ moduleName : String { moduleName : List String
, rest : List ( String, AddFormHelp.Kind ) , rest : List ( String, AddFormHelp.Kind )
} }
@ -42,7 +42,7 @@ run =
let let
file : Elm.File file : Elm.File
file = file =
createFile (cliOptions.moduleName |> String.split ".") cliOptions.rest createFile cliOptions.moduleName cliOptions.rest
in in
Script.writeFile Script.writeFile
{ path = "app/" ++ file.path { path = "app/" ++ file.path

View File

@ -51,9 +51,14 @@ import Pages.Internal.RoutePattern as RoutePattern
{-| A positional argument for elm-cli-options-parser that does a Regex validation to check that the module name is a valid Elm Route module name. {-| A positional argument for elm-cli-options-parser that does a Regex validation to check that the module name is a valid Elm Route module name.
-} -}
moduleNameCliArg : Option.Option from String builderState -> Option.Option from String builderState moduleNameCliArg : Option.Option from String builderState -> Option.Option from (List String) builderState
moduleNameCliArg = moduleNameCliArg =
Option.validate (Cli.Validate.regex moduleNameRegex) Option.validate
(Cli.Validate.regex moduleNameRegex)
>> Option.map
(\rawModuleName ->
rawModuleName |> String.split "."
)
moduleNameRegex : String moduleNameRegex : String