This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2944 from kodebach/codegen
Codegen: Ignore missing required keys in help mode
- Loading branch information
Showing
25 changed files
with
512 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# High-level API Help Message | ||
|
||
This decision _does not_ assume code-generation is used. For the case of code-generation see the [Notes](#notes) section. | ||
|
||
## Problem | ||
|
||
We want to allow to print the help message no matter what errors happened in `kdbOpen` or `kdbGet`. | ||
|
||
## Constraints | ||
|
||
- `elektraOpen` should not return a broken `Elektra` instance. | ||
- The help message can only be printed, if `elektraOpen` returns an `Elektra` instance and no `ElektraError`. | ||
|
||
## Assumptions | ||
|
||
- We assume that the application in question was correctly installed. | ||
- We assume `gopts` was mounted. | ||
- We assume the application was called in _help mode_, i.e. with `-h` or `--help`. | ||
Otherwise printing the help message is not possible, anyway. | ||
|
||
## Considered Alternatives | ||
|
||
- Ignore all errors (in help mode): | ||
Not a feasible solution, because there may have been problems when reading the storage file and therefore, | ||
the help message may be broken or incomplete. | ||
- Ignore all errors (in help mode), which occurred after the `gopts` plugin ran: | ||
Complicated to implement (we need to know about plugin order, etc.). | ||
Not actually necessary (see [Rationale](#rationale)). | ||
|
||
## Decision | ||
|
||
Ignore missing `require`d keys (in help mode), but fail for every other error. | ||
|
||
## Rationale | ||
|
||
Required keys **must** be provided by the user/admin and cannot come from another source (Elektra, app developer, etc.). | ||
Therefore they will be missing until the user makes changes to the KDB. Before that, no other error should occur (we | ||
assumed a correct installation). If a user runs `app` for the first time and receives an error about a missing required | ||
key, they will: | ||
|
||
- know what to do and add the key, thereby fixing the problem. | ||
- try `app -h`/`app --help` to find out more. The help message may or may not contain useful information. If not they may try 3. | ||
- read some other documentation to find out more. Ideally this leads them to 1. | ||
|
||
In any case after this the user definitely know how to interact with the KDB. Since we assumed that there won't be any | ||
errors before the KDB was changed, we can assume that the user caused other errors by changing the KDB. | ||
|
||
## Notes | ||
|
||
If code-generation is used, the situation is a little different. If the parameter `embedHelpFallback` is set to `1`, a | ||
fallback help message will be created from the specification originally passed to the code-generator and embedded into | ||
the application. The parameter also changes, how help mode is detected and ultimately allows the help message function | ||
(`printHelpMessage` by default) to always print a help message. Although it may not reflect changes the user made to the | ||
specification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.