2022-08-03 14:20:40 +03:00
|
|
|
module Commands.Dev.Scope where
|
2022-05-06 12:48:07 +03:00
|
|
|
|
2022-07-12 20:08:03 +03:00
|
|
|
import GlobalOptions
|
2022-08-03 14:20:40 +03:00
|
|
|
import Juvix.Compiler.Concrete.Pretty qualified as Scoper
|
2022-07-08 14:59:45 +03:00
|
|
|
import Juvix.Prelude hiding (Doc)
|
2022-05-06 12:48:07 +03:00
|
|
|
import Options.Applicative
|
|
|
|
|
2022-06-09 17:36:07 +03:00
|
|
|
newtype ScopeOptions = ScopeOptions
|
|
|
|
{ _scopeInlineImports :: Bool
|
2022-05-06 12:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
makeLenses ''ScopeOptions
|
|
|
|
|
|
|
|
parseScope :: Parser ScopeOptions
|
|
|
|
parseScope = do
|
|
|
|
_scopeInlineImports <-
|
|
|
|
switch
|
|
|
|
( long "inline-imports"
|
|
|
|
<> help "Show the code of imported modules next to the import statement"
|
|
|
|
)
|
|
|
|
pure ScopeOptions {..}
|
2022-07-12 20:08:03 +03:00
|
|
|
|
2022-09-12 11:44:00 +03:00
|
|
|
instance CanonicalProjection (GlobalOptions, ScopeOptions) Scoper.Options where
|
|
|
|
project (g, ScopeOptions {..}) =
|
|
|
|
Scoper.defaultOptions
|
|
|
|
{ Scoper._optShowNameIds = g ^. globalShowNameIds,
|
|
|
|
Scoper._optInlineImports = _scopeInlineImports
|
|
|
|
}
|