Describes how we expect the command cabal status
to behave from a high-level perspective.
> cabal status --output-format=json --compiler | jq
{
"cabal-version": "3.7.0.0",
"compiler": {
"flavour": "GHC",
"compiler-id": "ghc-7.10.2",
"path": "/usr/bin/ghc"
}
}
Cli:
--output-format
is mandatory. Only allowed value:json
(may be extended in the future)--compiler
composable selector
Output explanations:
- Mandatory:
cabal-version
denotes the output format version and follows thecabal-version
scheme compiler-id
is standardised to:<Compiler-Name>-<Version>
path
points to the same locationcabal
is usingflavour
is one of:GHC | GHCJS
Do we care about more fields?
Syntax:
> cabal status --output-format=json --target=./src/File.hs --target=./test/Main.hs --target=./non-existent/Main.hs | jq
{
"cabal-version": "3.7.0.0",
"target": [
{
"target": "./src/File.hs",
"unit-id": "foo-inplace"
},
{
"target": "./test/Main.hs",
"unit-id": "foo-testsuite-inplace"
},
{
"target": "./non-existent/Main.hs",
"unit-id": null
}
]
}
Cli:
--output-format
is mandatory. Only allowed value:json
(may be extended in the future)--target
can be given multiple times- argument is expected to be a cabal target, thus we allow:
components
(in all valid specifications),file-targets
- argument is expected to be a cabal target, thus we allow:
Output explanations:
- Mandatory:
cabal-version
denotes the output format version and follows thecabal-version
scheme target
, list of json object containing the relevant information- Original target parameter is the key in the json object
- unit-id of the target string
- If
unit-id
isnull
, no such target
Flags are composable and results are reported as one json object.
> cabal status --output-format=json --compiler --target=./src/File.hs --target=./test/Main.hs --target=./non-existent/Main.hs | jq
{
"version": "3.7.0.0",
"compiler": {
"flavour": "GHC",
"compiler-id": "ghc-7.10.2",
"path": "/usr/bin/ghc"
},
"targets": [
{
"target": "./src/File.hs",
"unit-id": "foo-inplace"
},
{
"target": "./test/Main.hs",
"unit-id": "foo-testsuite-inplace"
},
{
"target": "./non-existent/Main.hs",
"unit-id": null
}
]
}
Only one test
> cabal status --output-format=json --target=tests | jq
{
"version": "3.7.0.0",
"targets": [
{
"target": "tests",
"unit-id": "foo-tests-inplace"
}
]
}
Multiple executables, thus exes
resolves to multiple targets
> cabal status --output-format=json --target=exes | jq
{
"version": "3.7.0.0",
"compiler": {
"flavour": "GHC",
"compiler-id": "ghc-7.10.2",
"path": "/usr/bin/ghc"
},
"targets": [
{
"target": "exes",
"unit-id": "foo-exe1-inplace"
},
{
"target": "exes",
"unit-id": "foo-exe2-inplace"
}
]
}