-getHelp :: IO String
-getHelp =
- toString <$> Data.UUID.V4.nextRandom >>= \id ->
- appendFile ( "/tmp/xdg-ninja." ++ id ++ ".md" ) "Export the following environment variables:\n\n```bash\n\n```" >>
- createProcess (shell ("nvim /tmp/xdg-ninja." ++ id ++ ".md")) >>= \r ->
- case r of
- (_, _, _, p) ->
- waitForProcess p
- >>= ( \f -> case f of
- ExitSuccess -> readFile ("/tmp/xdg-ninja." ++ id ++ ".md")
- (ExitFailure a) -> return ""
- )
+data SupportLevel = Unsupported | Alias | EnvVars | Supported
+ deriving (Generic, Show)
+
+instance ToJSON SupportLevel where
+ toEncoding Unsupported = toEncoding ( Bool False )
+ toEncoding _ = toEncoding ( Bool True )
+
+getTemplate :: SupportLevel -> String
+getTemplate Unsupported = "Currently unsupported.\n\n_Relevant issue:_ https://github.com/user/repo/issues/nr\n"
+getTemplate EnvVars = "Export the following environment variables:\n\n```bash\n\n```"
+getTemplate Alias = "Alias PROGRAM to use a custom configuration location:\n\n```bash\nalias PROGRAM=PROGRAM --config \"$XDG_CONFIG_HOME\"/PROGRAM/config\n```\n"
+getTemplate Supported = "Supported since _VERSION_.\n\nYou can move the file to _XDG_CONFIG_HOME/PROGRAM/CONFIG.\n"
+
+
+getHelp :: SupportLevel -> IO String
+getHelp supportLevel = do
+ id <- toString <$> Data.UUID.V4.nextRandom
+ editor <- appendFile ("/tmp/xdg-ninja." ++ id ++ ".md") (getTemplate supportLevel) >> (getEnv "EDITOR")
+ (_, _, _, p) <- createProcess (shell (editor ++ " /tmp/xdg-ninja." ++ id ++ ".md"))
+ f <- waitForProcess p
+ case f of
+ ExitSuccess -> readFile ("/tmp/xdg-ninja." ++ id ++ ".md")
+ ExitFailure a -> return ""