Skip to content

Commit 50ca23b

Browse files
Merge branch 'release-1.8.0'. Refs #275.
2 parents 80b207a + 70356ff commit 50ca23b

37 files changed

+622
-71
lines changed

ogma-cli/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Revision history for ogma-cli
22

3+
## [1.8.0] - 2025-07-13
4+
5+
* Version bump 1.8.0 (#275).
6+
* Expose overview command (#272).
7+
* Extend code commands to accept expressions to monitor as CLI arguments (#121).
8+
39
## [1.7.0] - 2025-03-21
410

511
* Version bump 1.7.0 (#269).

ogma-cli/ogma-cli.cabal

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cabal-version: 2.0
3232
build-type: Simple
3333

3434
name: ogma-cli
35-
version: 1.7.0
35+
version: 1.8.0
3636
homepage: https://github.com/nasa/ogma
3737
bug-reports: https://github.com/nasa/ogma/issues
3838
license: OtherLicense
@@ -90,6 +90,7 @@ description: Ogma is a tool to facilitate the integration of safe runtim
9090
> -h,--help Show this help text
9191
>
9292
>Available commands:
93+
> overview Generate an overview of the input specification(s)
9394
> structs Generate Copilot structs from C structs
9495
> handlers Generate message handlers from C structs
9596
> cfs Generate a complete CFS/Copilot application
@@ -142,15 +143,20 @@ executable ogma
142143
CLI.CommandCStructs2MsgHandlers
143144
CLI.CommandDiagram
144145
CLI.CommandFPrimeApp
146+
CLI.CommandOverview
145147
CLI.CommandROSApp
146148
CLI.CommandStandalone
147149
CLI.CommandTop
148150
CLI.Result
149151

150152
build-depends:
151153
base >= 4.11.0.0 && < 5
154+
, aeson >= 2.0.0.0 && < 2.3
152155
, optparse-applicative >= 0.14 && < 0.19
153-
, ogma-core >= 1.7.0 && < 1.8
156+
, microstache >= 1.0 && < 1.1
157+
, text >= 1.2.3.1 && < 2.2
158+
159+
, ogma-core >= 1.8.0 && < 1.9
154160

155161
hs-source-dirs:
156162
src

ogma-cli/src/CLI/CommandCFSApp.hs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ import qualified Command.CFSApp
5757

5858
-- | Options needed to generate the cFS application.
5959
data CommandOpts = CommandOpts
60-
{ cFSAppInputFile :: Maybe String
60+
{ cFSAppConditionExpr :: Maybe String
61+
, cFSAppInputFile :: Maybe String
6162
, cFSAppTarget :: String
6263
, cFSAppTemplateDir :: Maybe String
6364
, cFSAppVarNames :: Maybe String
@@ -78,7 +79,8 @@ command :: CommandOpts -> IO (Result ErrorCode)
7879
command c = Command.CFSApp.command options
7980
where
8081
options = Command.CFSApp.CommandOptions
81-
{ Command.CFSApp.commandInputFile = cFSAppInputFile c
82+
{ Command.CFSApp.commandConditionExpr = cFSAppConditionExpr c
83+
, Command.CFSApp.commandInputFile = cFSAppInputFile c
8284
, Command.CFSApp.commandTargetDir = cFSAppTarget c
8385
, Command.CFSApp.commandTemplateDir = cFSAppTemplateDir c
8486
, Command.CFSApp.commandVariables = cFSAppVarNames c
@@ -101,6 +103,13 @@ commandDesc = "Generate a complete cFS/Copilot application"
101103
commandOptsParser :: Parser CommandOpts
102104
commandOptsParser = CommandOpts
103105
<$> optional
106+
( strOption
107+
( long "condition-expr"
108+
<> metavar "EXPRESSION"
109+
<> help strCFSAppConditionExprArgDesc
110+
)
111+
)
112+
<*> optional
104113
( strOption
105114
( long "input-file"
106115
<> metavar "FILENAME"
@@ -182,6 +191,11 @@ strCFSAppTemplateDirArgDesc :: String
182191
strCFSAppTemplateDirArgDesc =
183192
"Directory holding cFS application source template"
184193

194+
-- | Argument expression to CFS app generation command.
195+
strCFSAppConditionExprArgDesc :: String
196+
strCFSAppConditionExprArgDesc =
197+
"Expression used as guard or trigger condition"
198+
185199
-- | Argument input file to CFS app generation command
186200
strCFSAppFileNameArgDesc :: String
187201
strCFSAppFileNameArgDesc =

ogma-cli/src/CLI/CommandFPrimeApp.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ import qualified Command.FPrimeApp
5757

5858
-- | Options needed to generate the FPrime component.
5959
data CommandOpts = CommandOpts
60-
{ fprimeAppInputFile :: Maybe String
60+
{ fprimeAppConditionExpr :: Maybe String
61+
, fprimeAppInputFile :: Maybe String
6162
, fprimeAppTarget :: String
6263
, fprimeAppTemplateDir :: Maybe String
6364
, fprimeAppVariables :: Maybe String
@@ -79,7 +80,8 @@ command c = Command.FPrimeApp.command options
7980
where
8081
options =
8182
Command.FPrimeApp.CommandOptions
82-
{ Command.FPrimeApp.commandInputFile = fprimeAppInputFile c
83+
{ Command.FPrimeApp.commandConditionExpr = fprimeAppConditionExpr c
84+
, Command.FPrimeApp.commandInputFile = fprimeAppInputFile c
8385
, Command.FPrimeApp.commandTargetDir = fprimeAppTarget c
8486
, Command.FPrimeApp.commandTemplateDir = fprimeAppTemplateDir c
8587
, Command.FPrimeApp.commandVariables = fprimeAppVariables c
@@ -102,6 +104,13 @@ commandDesc = "Generate a complete F' monitoring component"
102104
commandOptsParser :: Parser CommandOpts
103105
commandOptsParser = CommandOpts
104106
<$> optional
107+
( strOption
108+
( long "condition-expr"
109+
<> metavar "EXPRESSION"
110+
<> help strFPrimeAppConditionExprArgDesc
111+
)
112+
)
113+
<*> optional
105114
( strOption
106115
( long "input-file"
107116
<> metavar "FILENAME"
@@ -183,6 +192,10 @@ strFPrimeAppTemplateDirArgDesc :: String
183192
strFPrimeAppTemplateDirArgDesc =
184193
"Directory holding F' component source template"
185194

195+
-- | Argument expression to FPrime app generation command.
196+
strFPrimeAppConditionExprArgDesc :: String
197+
strFPrimeAppConditionExprArgDesc = "Expression used as guard or trigger condition"
198+
186199
-- | Argument input file to FPrime component generation command
187200
strFPrimeAppFileNameArgDesc :: String
188201
strFPrimeAppFileNameArgDesc =
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
-- Copyright 2020 United States Government as represented by the Administrator
3+
-- of the National Aeronautics and Space Administration. All Rights Reserved.
4+
--
5+
-- Disclaimers
6+
--
7+
-- No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY
8+
-- OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
9+
-- LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
10+
-- SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
11+
-- PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE
12+
-- SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF
13+
-- PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN
14+
-- ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR
15+
-- RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR
16+
-- ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER,
17+
-- GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING
18+
-- THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES
19+
-- IT "AS IS."
20+
--
21+
-- Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST
22+
-- THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS
23+
-- ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN
24+
-- ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE,
25+
-- INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S
26+
-- USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE
27+
-- UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
28+
-- PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY
29+
-- FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS
30+
-- AGREEMENT.
31+
--
32+
-- | CLI interface to the Overview subcommand.
33+
module CLI.CommandOverview
34+
(
35+
-- * Direct command access
36+
command
37+
, CommandOpts
38+
, ErrorCode
39+
40+
-- * CLI
41+
, commandDesc
42+
, commandOptsParser
43+
)
44+
where
45+
46+
-- External imports
47+
import Data.Aeson (toJSON)
48+
import qualified Data.Text.Lazy as T
49+
import qualified Data.Text.Lazy.IO as T
50+
import Options.Applicative (Parser, help, long, metavar, optional,
51+
short, showDefault, strOption, value)
52+
import Text.Microstache
53+
54+
-- External imports: command results
55+
import Command.Result ( Result(..) )
56+
57+
-- External imports: actions or commands supported
58+
import Command.Overview (ErrorCode)
59+
import qualified Command.Overview
60+
61+
-- * Command
62+
63+
-- | Options to generate an overview from the input specification(s).
64+
data CommandOpts = CommandOpts
65+
{ overviewFileName :: FilePath
66+
, overviewFormat :: String
67+
, overviewPropFormat :: String
68+
, overviewPropVia :: Maybe String
69+
}
70+
71+
-- | Print an overview of the input specification(s).
72+
command :: CommandOpts -> IO (Result ErrorCode)
73+
command c = do
74+
(mOutput, result) <-
75+
Command.Overview.command (overviewFileName c) internalCommandOpts
76+
77+
case (mOutput, outputString) of
78+
(Just output, Right template) ->
79+
T.putStr $ renderMustache template (toJSON output)
80+
_ -> putStrLn "Error"
81+
return result
82+
83+
where
84+
internalCommandOpts :: Command.Overview.CommandOptions
85+
internalCommandOpts = Command.Overview.CommandOptions
86+
{ Command.Overview.commandFormat = overviewFormat c
87+
, Command.Overview.commandPropFormat = overviewPropFormat c
88+
, Command.Overview.commandPropVia = overviewPropVia c
89+
}
90+
91+
outputString = compileMustacheText "output" $ T.unlines
92+
[ "The file has:"
93+
, " - {{commandExternalVariables}} external variables."
94+
, " - {{commandInternalVariables}} internal variables."
95+
, " - {{commandRequirements}} requirements."
96+
]
97+
98+
-- * CLI
99+
100+
-- | Command description for CLI help.
101+
commandDesc :: String
102+
commandDesc = "Generate an overview of the input specification(s)"
103+
104+
-- | Subparser for the @overview@ command, used to generate an overview
105+
-- of the input specifications.
106+
commandOptsParser :: Parser CommandOpts
107+
commandOptsParser = CommandOpts
108+
<$> strOption
109+
( long "file-name"
110+
<> metavar "FILENAME"
111+
<> help strOverviewFilenameDesc
112+
)
113+
<*> strOption
114+
( long "input-format"
115+
<> short 'f'
116+
<> metavar "FORMAT_NAME"
117+
<> help strOverviewFormatDesc
118+
<> showDefault
119+
<> value "fcs"
120+
)
121+
<*> strOption
122+
( long "prop-format"
123+
<> short 'p'
124+
<> metavar "FORMAT_NAME"
125+
<> help strOverviewPropFormatDesc
126+
<> showDefault
127+
<> value "smv"
128+
)
129+
<*> optional
130+
( strOption
131+
( long "parse-prop-via"
132+
<> metavar "COMMAND"
133+
<> help strOverviewPropViaDesc
134+
)
135+
)
136+
137+
-- | Filename flag description.
138+
strOverviewFilenameDesc :: String
139+
strOverviewFilenameDesc = "File with properties or requirements"
140+
141+
-- | Format flag description.
142+
strOverviewFormatDesc :: String
143+
strOverviewFormatDesc = "Format of the input file"
144+
145+
-- | Property format flag description.
146+
strOverviewPropFormatDesc :: String
147+
strOverviewPropFormatDesc = "Format of temporal or boolean properties"
148+
149+
-- | External command to pre-process individual properties.
150+
strOverviewPropViaDesc :: String
151+
strOverviewPropViaDesc =
152+
"Command to pre-process individual properties"

ogma-cli/src/CLI/CommandROSApp.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ import qualified Command.ROSApp
5757

5858
-- | Options needed to generate the ROS application.
5959
data CommandOpts = CommandOpts
60-
{ rosAppInputFile :: Maybe String
60+
{ rosAppConditionExpr :: Maybe String
61+
, rosAppInputFile :: Maybe String
6162
, rosAppTarget :: String
6263
, rosAppTemplateDir :: Maybe String
6364
, rosAppVarNames :: Maybe String
@@ -78,7 +79,8 @@ command :: CommandOpts -> IO (Result ErrorCode)
7879
command c = Command.ROSApp.command options
7980
where
8081
options = Command.ROSApp.CommandOptions
81-
{ Command.ROSApp.commandInputFile = rosAppInputFile c
82+
{ Command.ROSApp.commandConditionExpr = rosAppConditionExpr c
83+
, Command.ROSApp.commandInputFile = rosAppInputFile c
8284
, Command.ROSApp.commandTargetDir = rosAppTarget c
8385
, Command.ROSApp.commandTemplateDir = rosAppTemplateDir c
8486
, Command.ROSApp.commandVariables = rosAppVarNames c
@@ -101,6 +103,13 @@ commandDesc = "Generate a ROS 2 monitoring package"
101103
commandOptsParser :: Parser CommandOpts
102104
commandOptsParser = CommandOpts
103105
<$> optional
106+
( strOption
107+
( long "condition-expr"
108+
<> metavar "EXPRESSION"
109+
<> help strROSAppConditionExprArgDesc
110+
)
111+
)
112+
<*> optional
104113
( strOption
105114
( long "input-file"
106115
<> metavar "FILENAME"
@@ -182,6 +191,10 @@ strROSAppTemplateDirArgDesc :: String
182191
strROSAppTemplateDirArgDesc =
183192
"Directory holding ROS application source template"
184193

194+
-- | Argument expression to ROS app generation command.
195+
strROSAppConditionExprArgDesc :: String
196+
strROSAppConditionExprArgDesc = "Expression used as guard or trigger condition"
197+
185198
-- | Argument input file to ROS app generation command
186199
strROSAppFileNameArgDesc :: String
187200
strROSAppFileNameArgDesc =

ogma-cli/src/CLI/CommandStandalone.hs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ import qualified Command.Standalone
6060
data CommandOpts = CommandOpts
6161
{ standaloneTargetDir :: FilePath
6262
, standaloneTemplateDir :: Maybe FilePath
63-
, standaloneFileName :: FilePath
63+
, standaloneConditionExpr :: Maybe String
64+
, standaloneFileName :: Maybe FilePath
6465
, standaloneFormat :: String
6566
, standalonePropFormat :: String
6667
, standaloneTypes :: [String]
@@ -76,7 +77,8 @@ command c =
7677
where
7778
internalCommandOpts :: Command.Standalone.CommandOptions
7879
internalCommandOpts = Command.Standalone.CommandOptions
79-
{ Command.Standalone.commandInputFile = standaloneFileName c
80+
{ Command.Standalone.commandConditionExpr = standaloneConditionExpr c
81+
, Command.Standalone.commandInputFile = standaloneFileName c
8082
, Command.Standalone.commandTargetDir = standaloneTargetDir c
8183
, Command.Standalone.commandTemplateDir = standaloneTemplateDir c
8284
, Command.Standalone.commandFormat = standaloneFormat c
@@ -121,10 +123,19 @@ commandOptsParser = CommandOpts
121123
<> help strStandaloneTemplateDirArgDesc
122124
)
123125
)
124-
<*> strOption
125-
( long "file-name"
126-
<> metavar "FILENAME"
127-
<> help strStandaloneFilenameDesc
126+
<*> optional
127+
( strOption
128+
( long "condition-expr"
129+
<> metavar "FILENAME"
130+
<> help strStandaloneConditionExprDesc
131+
)
132+
)
133+
<*> optional
134+
( strOption
135+
( long "file-name"
136+
<> metavar "FILENAME"
137+
<> help strStandaloneFilenameDesc
138+
)
128139
)
129140
<*> strOption
130141
( long "input-format"
@@ -179,6 +190,11 @@ strStandaloneTargetDirDesc = "Target directory"
179190
strStandaloneTemplateDirArgDesc :: String
180191
strStandaloneTemplateDirArgDesc = "Directory holding standalone source template"
181192

193+
-- | Condition flag description.
194+
strStandaloneConditionExprDesc :: String
195+
strStandaloneConditionExprDesc =
196+
"Condition upon which the monitor will fire or notify"
197+
182198
-- | Filename flag description.
183199
strStandaloneFilenameDesc :: String
184200
strStandaloneFilenameDesc = "File with properties or requirements"

0 commit comments

Comments
 (0)