Skip to content

Commit fe63257

Browse files
committed
[cli] Add code design decisions docs with opt-env-conf considerations
1 parent b26ca71 commit fe63257

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

cli/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ will show you all the available facts you can query.
186186

187187
## Design
188188

189-
[Design document](docs/antithesis-interface.md)
189+
[Interface Design document](docs/antithesis-interface.md)
190+
[Code Design Decisions](docs/code-design-decisions.md)
190191

191192
## Manuals
192193

cli/docs/code-design-decisions.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Code Design Decisions
2+
3+
## opt-env-conf vs optparse-applicative
4+
5+
Optparse-applicative is a popular library for parsing command-line options in Haskell. It provides a declarative way to define command-line interfaces and supports features like subcommands, flags, and arguments.
6+
7+
Opt-env-conf is a library that extends optparse-applicative by adding support for environment variables and configuration files. It allows developers to define options that can be set via command-line arguments, environment variables, or configuration files, providing more flexibility in how applications can be configured.
8+
9+
### Decision
10+
11+
We chose to use opt-env-conf over optparse-applicative for the following reasons:
12+
1. Some commands require some env vars to be set, while others don't. opt-env-conf allows us to handle this complexity more gracefully, wihout passing around Maybe values.
13+
2. We need to handle both encrypted and unencrypted mnemonics. Depending on that the settings are different. opt-env-conf allows us to define different settings based on the context, making it easier to manage these variations. In particular after parsing the env var ANTI_WALLET_FILE we insert a read-only operation (checkMapIO) that brings in the fields of the wallet file as settings. Depending on the field we require different settings for the passphrase.
14+
3. We want to support interactive prompts for sensitive information like passwords. opt-env-conf `mapIO` allows us to introduce interactive prompts as part of the settings parsing process, making it easier to handle user input securely.

0 commit comments

Comments
 (0)