adr-tools creates the .adr-dir file on init and then uses that for subsequent runs to decide where to put/get ADRs. This works fine, and I've reproduced this behavior in adrs, but I think it would be cleaner to use a global flag tied to an environment variable, as well as just use the docs/adr as a default everywhere.
The flow would be something like this:
If no .adr-dir exists, and no docs/adr exists, default to docs/adr without writing a .adr-dir file
If the global --directory flag is set for any command, use that value for all operations, even if a .adr-dir exists.
If the ADR_DIRECTORY environment variable is set, use that value for all operations even if a .adr-dir exists.
If no .adr-dir exists but the docs/adr directory does exist, use the docs/adr directory.
I think this covers most potential situations while maintaining backwards compatibility and keeping sane defaults.
Steps off the top of my head:
Add the directory flag in main.rs as a global flag, with the env marker to also pull it from the environment.
Process the flag before calling the subcommand, and pass the directory value to any subcommand as a Path (or maybe PathBuf?).
Change anything that uses .adr-dir now to always use that value.
adr-tools
creates the .adr-dir file oninit
and then uses that for subsequent runs to decide where to put/get ADRs. This works fine, and I've reproduced this behavior in adrs, but I think it would be cleaner to use a global flag tied to an environment variable, as well as just use thedocs/adr
as a default everywhere.The flow would be something like this:
.adr-dir
exists, and nodocs/adr
exists, default todocs/adr
without writing a.adr-dir
file--directory
flag is set for any command, use that value for all operations, even if a.adr-dir
exists.ADR_DIRECTORY
environment variable is set, use that value for all operations even if a.adr-dir
exists..adr-dir
exists but thedocs/adr
directory does exist, use thedocs/adr
directory.I think this covers most potential situations while maintaining backwards compatibility and keeping sane defaults.
Steps off the top of my head:
directory
flag inmain.rs
as a global flag, with theenv
marker to also pull it from the environment.directory
value to any subcommand as aPath
(or maybePathBuf
?)..adr-dir
now to always use that value.