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-formatis mandatory. Only allowed value:json(may be extended in the future)--compilercomposable selector
Output explanations:
- Mandatory:
cabal-versiondenotes the output format version and follows thecabal-versionscheme compiler-idis standardised to:<Compiler-Name>-<Version>pathpoints to the same locationcabalis usingflavouris 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-formatis mandatory. Only allowed value:json(may be extended in the future)--targetcan 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-versiondenotes the output format version and follows thecabal-versionscheme 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-idisnull, 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"
}
]
}