Skip to content

Commit

Permalink
ogma-core: Enable customizing template directory in standalone comman…
Browse files Browse the repository at this point in the history
…d. Refs nasa#189.

The standalone backend uses a fixed template to generate the Copilot
monitor. That template does not fit all use cases, so we are finding
users heavily modifying the output (which is hard to keep up with when
there are changes), or not using ogma altogether for that reason.

A prior commit introduced, in the standalone command, the ability to use
mustache to expand variables in a template.

This commit modifies the standalone command to accept an additional
argument that points to a user-provided directory with a custom
template.
  • Loading branch information
ivanperez-keera committed Dec 24, 2024
1 parent 8bdc8a3 commit 5270ed5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ogma-core/src/Command/Standalone.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ standalone :: FilePath -- ^ Path to a file containing a specification
standalone fp options = do
E.handle (return . standaloneTemplateError options fp) $ do
-- Obtain template dir
dataDir <- getDataDir
let templateDir = dataDir </> "templates" </> "standalone"
templateDir <- case standaloneTemplateDir options of
Just x -> return x
Nothing -> do
dataDir <- getDataDir
return $ dataDir </> "templates" </> "standalone"

let functions = exprPair (standalonePropFormat options)

Expand Down Expand Up @@ -156,6 +159,7 @@ standalone' fp options (ExprPair parse replace print ids) = do
-- code.
data StandaloneOptions = StandaloneOptions
{ standaloneTargetDir :: FilePath
, standaloneTemplateDir :: Maybe FilePath
, standaloneFormat :: String
, standalonePropFormat :: String
, standaloneTypeMapping :: [(String, String)]
Expand Down

0 comments on commit 5270ed5

Please sign in to comment.