Skip to content

Commit

Permalink
ogma-cli: Provide CLI argument to set auxiliary template source direc…
Browse files Browse the repository at this point in the history
…tory in standalone command. 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), and or not using ogma altogether for that reason.

A recent commit introduced into ogma-core the ability to use a custom
template and expand variables using mustache.

This commit exposes that new parameter to the user in the CLI.
  • Loading branch information
ivanperez-keera committed Dec 24, 2024
1 parent f2baa59 commit 253efc4
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions ogma-cli/src/CLI/CommandStandalone.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module CLI.CommandStandalone
where

-- External imports
import Options.Applicative (Parser, help, long, metavar, many, short,
import Options.Applicative (Parser, help, long, many, metavar, optional, short,
showDefault, strOption, switch, value)

-- External imports: command results
Expand All @@ -58,12 +58,13 @@ import qualified Command.Standalone

-- | Options to generate Copilot from specification.
data CommandOpts = CommandOpts
{ standaloneTargetDir :: FilePath
, standaloneFileName :: FilePath
, standaloneFormat :: String
, standalonePropFormat :: String
, standaloneTypes :: [String]
, standaloneTarget :: String
{ standaloneTargetDir :: FilePath
, standaloneTemplateDir :: Maybe FilePath
, standaloneFileName :: FilePath
, standaloneFormat :: String
, standalonePropFormat :: String
, standaloneTypes :: [String]
, standaloneTarget :: String
}

-- | Transform an input specification into a Copilot specification.
Expand All @@ -73,6 +74,7 @@ command c = standalone (standaloneFileName c) internalCommandOpts
internalCommandOpts :: Command.Standalone.StandaloneOptions
internalCommandOpts = Command.Standalone.StandaloneOptions
{ Command.Standalone.standaloneTargetDir = standaloneTargetDir c
, Command.Standalone.standaloneTemplateDir = standaloneTemplateDir c
, Command.Standalone.standaloneFormat = standaloneFormat c
, Command.Standalone.standalonePropFormat = standalonePropFormat c
, Command.Standalone.standaloneTypeMapping = types
Expand Down Expand Up @@ -106,6 +108,13 @@ commandOptsParser = CommandOpts
<> value "copilot"
<> help strStandaloneTargetDirDesc
)
<*> optional
( strOption
( long "template-dir"
<> metavar "DIR"
<> help strStandaloneTemplateDirArgDesc
)
)
<*> strOption
( long "file-name"
<> metavar "FILENAME"
Expand Down Expand Up @@ -146,6 +155,10 @@ commandOptsParser = CommandOpts
strStandaloneTargetDirDesc :: String
strStandaloneTargetDirDesc = "Target directory"

-- | Template dir flag description.
strStandaloneTemplateDirArgDesc :: String
strStandaloneTemplateDirArgDesc = "Directory holding standalone source template"

-- | Filename flag description.
strStandaloneFilenameDesc :: String
strStandaloneFilenameDesc = "File with properties or requirements"
Expand Down

0 comments on commit 253efc4

Please sign in to comment.