diff options
author | eric <thul.eric@gmail.com> | 2015-11-07 15:06:39 -0500 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2015-11-07 15:06:39 -0500 |
commit | d18adcf960b5df464971e7c06366feeb0d173f1b (patch) | |
tree | 6821a4e1fb1f5ab0c54f4e8434e1c5c717890967 /src/PursLoader/Options.purs | |
parent | 57585908acc300daa55b40156eeff7a065fe2832 (diff) | |
parent | 04eb392f345262e340717812e51a3ba810f7eaee (diff) | |
download | purs-loader-d18adcf960b5df464971e7c06366feeb0d173f1b.tar.gz purs-loader-d18adcf960b5df464971e7c06366feeb0d173f1b.tar.zst purs-loader-d18adcf960b5df464971e7c06366feeb0d173f1b.zip |
Merge pull request #30 from natefaubion/fix-paths
Fix paths
Diffstat (limited to 'src/PursLoader/Options.purs')
-rw-r--r-- | src/PursLoader/Options.purs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/PursLoader/Options.purs b/src/PursLoader/Options.purs index e3957eb..1650652 100644 --- a/src/PursLoader/Options.purs +++ b/src/PursLoader/Options.purs | |||
@@ -2,9 +2,11 @@ module PursLoader.Options | |||
2 | ( pscOptions | 2 | ( pscOptions |
3 | , loaderSrcOption | 3 | , loaderSrcOption |
4 | , loaderFFIOption | 4 | , loaderFFIOption |
5 | , Options() | ||
6 | , output | ||
5 | ) where | 7 | ) where |
6 | 8 | ||
7 | import Prelude (Unit(), (<>), (<$>), (<<<), (++), (<*>), const) | 9 | import Prelude (Unit(), (<>), (<$>), (<<<), (++), (<*>), ($), const, id) |
8 | 10 | ||
9 | import Data.Array (concat) | 11 | import Data.Array (concat) |
10 | import Data.Either (either) | 12 | import Data.Either (either) |
@@ -44,13 +46,16 @@ newtype Options | |||
44 | , noTco :: NullOrUndefined Boolean | 46 | , noTco :: NullOrUndefined Boolean |
45 | , verboseErrors :: NullOrUndefined Boolean | 47 | , verboseErrors :: NullOrUndefined Boolean |
46 | , comments :: NullOrUndefined Boolean | 48 | , comments :: NullOrUndefined Boolean |
47 | , output :: NullOrUndefined String | 49 | , output :: String |
48 | , noPrefix :: NullOrUndefined Boolean | 50 | , noPrefix :: NullOrUndefined Boolean |
49 | , requirePath :: NullOrUndefined String | 51 | , requirePath :: String |
50 | , src :: NullOrUndefined (Array String) | 52 | , src :: NullOrUndefined (Array String) |
51 | , ffi :: NullOrUndefined (Array String) | 53 | , ffi :: NullOrUndefined (Array String) |
52 | } | 54 | } |
53 | 55 | ||
56 | output :: Options -> String | ||
57 | output (Options o) = o.output | ||
58 | |||
54 | instance isForeignOptions :: IsForeign Options where | 59 | instance isForeignOptions :: IsForeign Options where |
55 | read obj = Options <$> ({ noPrelude: _ | 60 | read obj = Options <$> ({ noPrelude: _ |
56 | , noOpts: _ | 61 | , noOpts: _ |
@@ -60,7 +65,7 @@ instance isForeignOptions :: IsForeign Options where | |||
60 | , comments: _ | 65 | , comments: _ |
61 | , output: _ | 66 | , output: _ |
62 | , noPrefix: _ | 67 | , noPrefix: _ |
63 | , requirePath: _ | 68 | , requirePath: "../" |
64 | , src: _ | 69 | , src: _ |
65 | , ffi: _ | 70 | , ffi: _ |
66 | } <$> readProp noPreludeOpt obj | 71 | } <$> readProp noPreludeOpt obj |
@@ -69,9 +74,8 @@ instance isForeignOptions :: IsForeign Options where | |||
69 | <*> readProp noTcoOpt obj | 74 | <*> readProp noTcoOpt obj |
70 | <*> readProp verboseErrorsOpt obj | 75 | <*> readProp verboseErrorsOpt obj |
71 | <*> readProp commentsOpt obj | 76 | <*> readProp commentsOpt obj |
72 | <*> readProp outputOpt obj | 77 | <*> (maybe "output" id <<< runNullOrUndefined <$> readProp outputOpt obj) |
73 | <*> readProp noPrefixOpt obj | 78 | <*> readProp noPrefixOpt obj |
74 | <*> readProp requirePathOpt obj | ||
75 | <*> readProp srcOpt obj | 79 | <*> readProp srcOpt obj |
76 | <*> readProp ffiOpt obj) | 80 | <*> readProp ffiOpt obj) |
77 | 81 | ||
@@ -88,19 +92,17 @@ instance arrayLoaderOption :: (LoaderOption a) => LoaderOption (Array a) where | |||
88 | opt key val = concat (opt key <$> (NullOrUndefined <<< Just) | 92 | opt key val = concat (opt key <$> (NullOrUndefined <<< Just) |
89 | <$> (fromMaybe [] (runNullOrUndefined val))) | 93 | <$> (fromMaybe [] (runNullOrUndefined val))) |
90 | 94 | ||
91 | pscOptions :: Foreign -> Array String | 95 | pscOptions :: Options -> Array String |
92 | pscOptions query = either (const []) fold parsed | 96 | pscOptions (Options a) = opt noPreludeOpt a.noPrelude <> |
93 | where parsed = read query :: F Options | 97 | opt noOptsOpt a.noOpts <> |
94 | fold (Options a) = opt noPreludeOpt a.noPrelude <> | 98 | opt noMagicDoOpt a.noMagicDo <> |
95 | opt noOptsOpt a.noOpts <> | 99 | opt noTcoOpt a.noTco <> |
96 | opt noMagicDoOpt a.noMagicDo <> | 100 | opt verboseErrorsOpt a.verboseErrors <> |
97 | opt noTcoOpt a.noTco <> | 101 | opt commentsOpt a.comments <> |
98 | opt verboseErrorsOpt a.verboseErrors <> | 102 | opt outputOpt (NullOrUndefined $ Just a.output) <> |
99 | opt commentsOpt a.comments <> | 103 | opt noPrefixOpt a.noPrefix <> |
100 | opt outputOpt a.output <> | 104 | opt requirePathOpt (NullOrUndefined $ Just a.requirePath) <> |
101 | opt noPrefixOpt a.noPrefix <> | 105 | opt ffiOpt a.ffi |
102 | opt requirePathOpt a.requirePath <> | ||
103 | opt ffiOpt a.ffi | ||
104 | 106 | ||
105 | loaderSrcOption :: Foreign -> Maybe (Array String) | 107 | loaderSrcOption :: Foreign -> Maybe (Array String) |
106 | loaderSrcOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.src) (read query) | 108 | loaderSrcOption query = either (const Nothing) (\(Options a) -> runNullOrUndefined a.src) (read query) |