diff options
| author | Iyaan Azeez <iyaanazeez757@gmail.com> | 2026-01-14 15:52:27 +0500 |
|---|---|---|
| committer | Iyaan Azeez <iyaanazeez757@gmail.com> | 2026-01-14 15:52:27 +0500 |
| commit | c542aa57c87c805f53bba89a1018861194f07127 (patch) | |
| tree | 73725fa89f61111e17eb032917db14b9a9bd6a44 /tools | |
| parent | 03d564b758d8c3942bcea7dc1eff6ad8211b71ea (diff) | |
Feat: Add support for odinfmt custom config path
Introduces a new argument to -config which allows a
user to pass a json config for the formatter which is not
neccesarilly in the path of the files we are formatting.
For now the function will use the default_style if any errors
occur. This was done due to that being the pattern in the source
code. I think it would be useful to know if reading a config
has failed or has defaulted to a default style but, I wanted to not
include that in this.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/odinfmt/main.odin | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/odinfmt/main.odin b/tools/odinfmt/main.odin index 3470ca5..5096683 100644 --- a/tools/odinfmt/main.odin +++ b/tools/odinfmt/main.odin @@ -17,6 +17,7 @@ Args :: struct { write: bool `args:"name=w" usage:"write the new format to file"`, stdin: bool `usage:"formats code from standard input"`, path: string `args:"pos=0" usage:"set the file or directory to format"`, + config: string `usage:"path to a config file"` } format_file :: proc(filepath: string, config: printer.Config, allocator := context.allocator) -> (string, bool) { @@ -72,7 +73,12 @@ main :: proc() { watermark := 0 - config := format.find_config_file_or_default(args.path) + config: printer.Config + if args.config == "" { + config = format.find_config_file_or_default(args.path) + } else { + config = format.read_config_file_from_path_or_default(args.config) + } if args.stdin { data := make([dynamic]byte, arena_allocator) |