Extended --map-file docs
This commit is contained in:
parent
92f53f7b3b
commit
ddfcd6c281
@ -13,6 +13,8 @@
|
|||||||
--
|
--
|
||||||
-- You should have received a copy of the GNU Affero General Public License
|
-- You should have received a copy of the GNU Affero General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
|
||||||
|
|
||||||
module GHCMod.Options (
|
module GHCMod.Options (
|
||||||
parseArgs,
|
parseArgs,
|
||||||
@ -27,6 +29,7 @@ import Control.Arrow
|
|||||||
import GHCMod.Options.Commands
|
import GHCMod.Options.Commands
|
||||||
import GHCMod.Version
|
import GHCMod.Version
|
||||||
import GHCMod.Options.DocUtils
|
import GHCMod.Options.DocUtils
|
||||||
|
import GHCMod.Options.Help
|
||||||
import GHCMod.Options.ShellParse
|
import GHCMod.Options.ShellParse
|
||||||
|
|
||||||
parseArgs :: IO (Options, GhcModCommands)
|
parseArgs :: IO (Options, GhcModCommands)
|
||||||
@ -148,43 +151,27 @@ globalArgSpec = Options
|
|||||||
<=> help "Option to be passed to GHC"
|
<=> help "Option to be passed to GHC"
|
||||||
<*> many fileMappingSpec
|
<*> many fileMappingSpec
|
||||||
where
|
where
|
||||||
{-
|
|
||||||
File map docs:
|
|
||||||
|
|
||||||
CLI options:
|
|
||||||
* `--map-file "file1.hs=file2.hs"` can be used to tell
|
|
||||||
ghc-mod that it should take source code for `file1.hs` from `file2.hs`.
|
|
||||||
`file1.hs` can be either full path, or path relative to project root.
|
|
||||||
`file2.hs` has to be either relative to project root,
|
|
||||||
or full path (preferred).
|
|
||||||
* `--map-file "file.hs"` can be used to tell ghc-mod that it should take
|
|
||||||
source code for `file.hs` from stdin. File end marker is `\n\EOT\n`,
|
|
||||||
i.e. `\x0A\x04\x0A`. `file.hs` may or may not exist, and should be
|
|
||||||
either full path, or relative to project root.
|
|
||||||
|
|
||||||
Interactive commands:
|
|
||||||
* `map-file file.hs` -- tells ghc-modi to read `file.hs` source from stdin.
|
|
||||||
Works the same as second form of `--map-file` CLI option.
|
|
||||||
* `unmap-file file.hs` -- unloads previously mapped file, so that it's
|
|
||||||
no longer mapped. `file.hs` can be full path or relative to
|
|
||||||
project root, either will work.
|
|
||||||
|
|
||||||
Exposed functions:
|
|
||||||
* `loadMappedFile :: FilePath -> FilePath -> GhcModT m ()` -- maps `FilePath`,
|
|
||||||
given as first argument to take source from `FilePath` given as second
|
|
||||||
argument. Works exactly the same as first form of `--map-file`
|
|
||||||
CLI option.
|
|
||||||
* `loadMappedFileSource :: FilePath -> String -> GhcModT m ()` -- maps
|
|
||||||
`FilePath`, given as first argument to have source as given
|
|
||||||
by second argument. Works exactly the same as second form of `--map-file`
|
|
||||||
CLI option, sans reading from stdin.
|
|
||||||
* `unloadMappedFile :: FilePath -> GhcModT m ()` -- unmaps `FilePath`, given as
|
|
||||||
first argument, and removes any temporary files created when file was
|
|
||||||
mapped. Works exactly the same as `unmap-file` interactive command
|
|
||||||
-}
|
|
||||||
fileMappingSpec =
|
fileMappingSpec =
|
||||||
getFileMapping . splitOn '=' <$> strOption
|
getFileMapping . splitOn '=' <$> strOption
|
||||||
$$ long "map-file"
|
$$ long "map-file"
|
||||||
<=> metavar "MAPPING"
|
<=> metavar "MAPPING"
|
||||||
<=> help "Redirect one file to another, --map-file \"file1.hs=file2.hs\""
|
<=> fileMappingHelp
|
||||||
|
fileMappingHelp = help' $ do
|
||||||
|
"Redirect one file to another"
|
||||||
|
"--map-file \"file1.hs=file2.hs\""
|
||||||
|
indent 4 $ do
|
||||||
|
"can be used to tell ghc-mod"
|
||||||
|
\\ "that it should take source code"
|
||||||
|
\\ "for `file1.hs` from `file2.hs`."
|
||||||
|
"`file1.hs` can be either full path,"
|
||||||
|
\\ "or path relative to project root."
|
||||||
|
"`file2.hs` has to be either relative to project root,"
|
||||||
|
\\ "or full path (preferred)"
|
||||||
|
"--map-file \"file.hs\""
|
||||||
|
indent 4 $ do
|
||||||
|
"can be used to tell ghc-mod that it should take"
|
||||||
|
\\ "source code for `file.hs` from stdin. File end"
|
||||||
|
\\ "marker is `\\n\\EOT\\n`, i.e. `\\x0A\\x04\\x0A`."
|
||||||
|
\\ "`file.hs` may or may not exist, and should be"
|
||||||
|
\\ "either full path, or relative to project root."
|
||||||
getFileMapping = second (\i -> if null i then Nothing else Just i)
|
getFileMapping = second (\i -> if null i then Nothing else Just i)
|
||||||
|
Loading…
Reference in New Issue
Block a user