|
@@ -2,12 +2,13 @@ module JobSearchExtension.RecUtils where
|
|
|
|
|
|
|
|
import Prelude
|
|
import Prelude
|
|
|
|
|
|
|
|
-import Data.Generic.Rep (class Generic)
|
|
|
|
|
-import Data.Show.Generic (genericShow)
|
|
|
|
|
-
|
|
|
|
|
import Command (class HighLevelCommand, CommandError, CommandWithOpts(..))
|
|
import Command (class HighLevelCommand, CommandError, CommandWithOpts(..))
|
|
|
import Data.Either (Either(..))
|
|
import Data.Either (Either(..))
|
|
|
|
|
+import Data.Foldable (foldl)
|
|
|
|
|
+import Data.Generic.Rep (class Generic)
|
|
|
|
|
+import Data.Show.Generic (genericShow)
|
|
|
import Data.String (codePointFromChar)
|
|
import Data.String (codePointFromChar)
|
|
|
|
|
+import Data.Tuple (Tuple(..))
|
|
|
import Effect.Aff (try)
|
|
import Effect.Aff (try)
|
|
|
import Parsing (Parser, runParser)
|
|
import Parsing (Parser, runParser)
|
|
|
import Parsing.Combinators (between, optional)
|
|
import Parsing.Combinators (between, optional)
|
|
@@ -17,6 +18,32 @@ import Parsing.String.Basic (number, space, takeWhile)
|
|
|
import Partial.Unsafe (unsafePartial)
|
|
import Partial.Unsafe (unsafePartial)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+data RecInsCommand = RecInsCommand {filePath :: String, recordType :: String, fields :: Array (Tuple String String)}
|
|
|
|
|
+data RecInsCommandResult
|
|
|
|
|
+ = RecInsCommandResult String
|
|
|
|
|
+ | RecInsCommandSuccess
|
|
|
|
|
+
|
|
|
|
|
+derive instance Generic RecInsCommandResult _
|
|
|
|
|
+instance Show RecInsCommandResult where show = genericShow
|
|
|
|
|
+
|
|
|
|
|
+data RecInsCommandError = RecInsCommandError CommandError
|
|
|
|
|
+
|
|
|
|
|
+derive instance Generic RecInsCommandError _
|
|
|
|
|
+instance Show RecInsCommandError where show = genericShow
|
|
|
|
|
+
|
|
|
|
|
+instance HighLevelCommand RecInsCommand RecInsCommandResult RecInsCommandError where
|
|
|
|
|
+ toCommand (RecInsCommand {filePath, recordType, fields}) =
|
|
|
|
|
+ let
|
|
|
|
|
+ fieldsArgs = foldl (\l (Tuple k v) -> l <> ["-f", k, "-v", v]) [] fields
|
|
|
|
|
+ args = ["--verbose", "-t", recordType] <> fieldsArgs <> [filePath]
|
|
|
|
|
+
|
|
|
|
|
+ in CommandWithOpts "recins" args
|
|
|
|
|
+
|
|
|
|
|
+ toResult "" = RecInsCommandSuccess
|
|
|
|
|
+ toResult s = RecInsCommandResult s
|
|
|
|
|
+
|
|
|
|
|
+ fromError t = RecInsCommandError t
|
|
|
|
|
+
|
|
|
data RecSelCommand = RecSelCommand {filePath :: String, recordType :: String}
|
|
data RecSelCommand = RecSelCommand {filePath :: String, recordType :: String}
|
|
|
data RecSelCommandResult = RecSelCommandResult (Array RecFileRecord)
|
|
data RecSelCommandResult = RecSelCommandResult (Array RecFileRecord)
|
|
|
|
|
|