Skip to content

Commit

Permalink
ogma-cli: Add CLI argument to standalone command to set target direct…
Browse files Browse the repository at this point in the history
…ory. 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, support for custom
templates. Unlike the prior implementation of the standalone command,
which printed the output to standard output, the new interface puts the
result in a file (or several files) included with the template.  To
implement this new functionality, we have added an argument to specify a
target directory for the generated standalone application, where the
files will be copied to.

This commit exposes that new parameter to set the target directory to
the user in the CLI.
  • Loading branch information
ivanperez-keera committed Dec 24, 2024
1 parent 8408589 commit 879cd57
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ogma-cli/src/CLI/CommandStandalone.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import qualified Command.Standalone

-- | Options to generate Copilot from specification.
data CommandOpts = CommandOpts
{ standaloneFileName :: FilePath
{ standaloneTargetDir :: FilePath
, standaloneFileName :: FilePath
, standaloneFormat :: String
, standalonePropFormat :: String
, standaloneTypes :: [String]
Expand All @@ -71,7 +72,8 @@ command c = standalone (standaloneFileName c) internalCommandOpts
where
internalCommandOpts :: Command.Standalone.StandaloneOptions
internalCommandOpts = Command.Standalone.StandaloneOptions
{ Command.Standalone.standaloneFormat = standaloneFormat c
{ Command.Standalone.standaloneTargetDir = standaloneTargetDir c
, Command.Standalone.standaloneFormat = standaloneFormat c
, Command.Standalone.standalonePropFormat = standalonePropFormat c
, Command.Standalone.standaloneTypeMapping = types
, Command.Standalone.standaloneFilename = standaloneTarget c
Expand All @@ -98,6 +100,13 @@ commandDesc =
commandOptsParser :: Parser CommandOpts
commandOptsParser = CommandOpts
<$> strOption
( long "target-dir"
<> metavar "DIR"
<> showDefault
<> value "copilot"
<> help strStandaloneTargetDirDesc
)
<*> strOption
( long "file-name"
<> metavar "FILENAME"
<> help strStandaloneFilenameDesc
Expand Down Expand Up @@ -133,6 +142,10 @@ commandOptsParser = CommandOpts
<> value "monitor"
)

-- | Target dir flag description.
strStandaloneTargetDirDesc :: String
strStandaloneTargetDirDesc = "Target directory"

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

0 comments on commit 879cd57

Please sign in to comment.