[CLI] simplified routes sorting

Route implements Ord so no need to import Internal stuff
parent 6795382b
......@@ -19,7 +19,6 @@ import Gargantext.Prelude
import Options.Applicative
import Servant.API
import Servant.API.Routes
import Servant.API.Routes.Internal.Route (routeMethod, routePath)
import Servant.API.WebSocket qualified as WS (WebSocketPending)
import Servant.Auth qualified as Servant
......@@ -54,10 +53,6 @@ instance HasRoutes Raw where
routesCLI :: CLIRoutes -> IO ()
routesCLI = \case
CLIR_list
-> do
let routes = getRoutes @(NamedRoutes API)
let cmpFunc r = (renderPath (r ^. routePath), r ^. routeMethod)
let sortedRoutes = sortBy (\a b -> compare (cmpFunc a) (cmpFunc b)) routes
traverse_ (T.putStrLn . renderRoute) sortedRoutes
-> traverse_ (T.putStrLn . renderRoute) . sort $ getRoutes @(NamedRoutes API)
(CLIR_export filePath)
-> B.writeFile filePath . BL.toStrict $ encodePretty (getRoutes @(NamedRoutes API))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment