diff --git a/src/Ide/Arguments.hs b/src/Ide/Arguments.hs index a7c5433ff5..39ced77cd2 100644 --- a/src/Ide/Arguments.hs +++ b/src/Ide/Arguments.hs @@ -30,6 +30,7 @@ import System.Environment data Arguments = VersionMode PrintVersion | ProbeToolsMode + | ListPluginsMode | BiosMode BiosAction | Ghcide GhcideArguments | VSCodeExtensionSchemaMode @@ -64,6 +65,7 @@ getArguments exeName plugins = execParser opts opts = info (( VersionMode <$> printVersionParser exeName <|> probeToolsParser exeName + <|> listPluginsParser <|> BiosMode <$> biosParser <|> Ghcide <$> arguments plugins ) @@ -90,6 +92,11 @@ probeToolsParser exeName = flag' ProbeToolsMode (long "probe-tools" <> help ("Show " ++ exeName ++ " version and other tools of interest")) +listPluginsParser :: Parser Arguments +listPluginsParser = + flag' ListPluginsMode + (long "list-plugins" <> help "List all avaliable plugins") + arguments :: IdePlugins IdeState -> Parser GhcideArguments arguments plugins = GhcideArguments <$> (commandP plugins <|> lspCommand <|> checkCommand) diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index 54a6e7af3f..b54a798603 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -13,6 +13,7 @@ import Control.Monad.Extra import qualified Data.Aeson.Encode.Pretty as A import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Default +import Data.List (sort) import qualified Data.Text as T import Development.IDE.Core.Rules import Development.IDE.Graph (ShakeOptions (shakeThreads)) @@ -25,7 +26,8 @@ import Ide.Arguments import Ide.Logger import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig, pluginsToVSCodeExtensionSchema) -import Ide.Types (IdePlugins, ipMap) +import Ide.Types (IdePlugins, PluginId (PluginId), + ipMap) import Ide.Version import qualified Language.LSP.Server as LSP import qualified System.Directory.Extra as IO @@ -51,6 +53,12 @@ defaultMain args idePlugins = do VersionMode PrintNumericVersion -> putStrLn haskellLanguageServerNumericVersion + ListPluginsMode -> do + let pluginNames = sort + $ map ((\(PluginId t) -> T.unpack t) . fst) + $ ipMap idePlugins + mapM_ putStrLn pluginNames + BiosMode PrintCradleType -> do dir <- IO.getCurrentDirectory hieYaml <- Session.findCradle def dir