diff --git a/README.md b/README.md index 6416383e..5c66d015 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,10 @@ This section describes the integration between a single formatter and full filenames can be passed. Eg: `[ "Makefile" ]`. * `command`: A list of arguments to execute the formatter. This will be - composed with the `args` attribute during invocation. The first argument + composed with the `options` attribute during invocation. The first argument is the name of the executable to run. -* `args`: A list of extra arguments to add to the command. This is typically +* `options`: A list of extra arguments to add to the command. This is typically project-specific arguments. NOTE: Formatters SHOULD adhere to the [formatter @@ -135,7 +135,7 @@ Example: In the `prjfmt.toml` file of the project: ```toml [formatters.ormolu] -args = [ +options = [ "--ghc-opt", "-XBangPatterns", "--ghc-opt", "-XPatternSynonyms", ] @@ -146,7 +146,7 @@ contains: ```toml command = ["ormolu", "--mode", "inplace"] files = ["*.hs"] -args = [] +options = [] ``` The project will first load `prjfmt.toml`, take note of the ormolu formatter, @@ -157,12 +157,12 @@ this in their config: [formatters.ormolu] command = ["ormolu", "--mode", "inplace"] files = ["*.hs"] -args = [ +options = [ "--ghc-opt", "-XBangPatterns", "--check-idempotence" ] ``` -Note how the empty ormolu `args` got overwritten by the project `args`. +Note how the empty ormolu `options` got overwritten by the project `options`. ## Related projects diff --git a/examples/monorepo/prjfmt.toml b/examples/monorepo/prjfmt.toml index b202db90..8479733f 100644 --- a/examples/monorepo/prjfmt.toml +++ b/examples/monorepo/prjfmt.toml @@ -3,7 +3,7 @@ files = "*.hs" # / "*.hs" / "Makefile" mandatory excludes = [ "haskell/" ] # blacklisted folder/files. command = "ormolu" -args = [ +options = [ "--ghc-opt", "-XBangPatterns", "--ghc-opt", "-XPatternSynonyms", "--ghc-opt", "-XTypeApplications", @@ -16,4 +16,4 @@ files = [ "*.rs" ] includes = [ "rust/" ] excludes = [] command = "cargo" -args = [ "fmt", "--" ] +options = [ "fmt", "--" ] diff --git a/src/command/init.rs b/src/command/init.rs index efe30551..4b53ce09 100644 --- a/src/command/init.rs +++ b/src/command/init.rs @@ -21,7 +21,7 @@ pub fn init_prjfmt(path: Option) -> anyhow::Result<()> { includes = [ "*." ] excludes = [] command = "" -args = [] +options = [] "#, ) .with_context(|| { diff --git a/src/formatters/check.rs b/src/formatters/check.rs index 86a53183..3a1684fa 100644 --- a/src/formatters/check.rs +++ b/src/formatters/check.rs @@ -19,7 +19,7 @@ pub fn check_prjfmt( .map(|(a, b)| { Ok(CmdContext { command: a.command.clone(), - args: a.args.clone(), + options: a.options.clone(), metadata: a.metadata.difference(&b.metadata).cloned().collect(), }) }) diff --git a/src/formatters/manifest.rs b/src/formatters/manifest.rs index 156b183e..13f8ff0f 100644 --- a/src/formatters/manifest.rs +++ b/src/formatters/manifest.rs @@ -26,7 +26,7 @@ pub fn create_prjfmt_manifest( let prjfmt = cmd.command; let manifest = CmdContext { command: prjfmt.to_string(), - args: cmd.args, + options: cmd.options, metadata: cmd.metadata, }; (prjfmt.to_string(), manifest) diff --git a/src/formatters/tool.rs b/src/formatters/tool.rs index 7119a3e5..ebcc037f 100644 --- a/src/formatters/tool.rs +++ b/src/formatters/tool.rs @@ -72,7 +72,7 @@ pub fn run_prjfmt(cwd: PathBuf, cache_dir: PathBuf) -> anyhow::Result<()> { .par_iter() .flat_map(|c| { c.metadata.par_iter().cloned().map(move |m| { - let arg = &c.args; + let arg = &c.options; let cmd_arg = &c.command; let path = &m.path; cmd!("{cmd_arg} {arg...} {path}").output() @@ -87,7 +87,7 @@ pub fn run_prjfmt(cwd: PathBuf, cache_dir: PathBuf) -> anyhow::Result<()> { if c.command == octx.command { CmdContext { command: c.command.clone(), - args: c.args.clone(), + options: c.options.clone(), metadata: octx.metadata.union(&c.metadata).cloned().collect(), } } else { @@ -214,7 +214,7 @@ pub fn create_command_context(prjfmt_toml: &PathBuf) -> Result> )?; Ok(CmdContext { command: config.command.clone().unwrap_or_default(), - args: config.args.clone().unwrap_or_default(), + options: config.options.clone().unwrap_or_default(), metadata: path_to_filemeta(list_files)?, }) }) @@ -241,7 +241,7 @@ pub struct FmtConfig { /// Command formatter to run pub command: Option, /// Argument for formatter - pub args: Option>, + pub options: Option>, } /// File extensions can be single string (e.g. "*.hs") or @@ -273,7 +273,7 @@ pub struct CmdContext { /// formatter command to run pub command: String, /// formatter arguments or flags - pub args: Vec, + pub options: Vec, /// formatter target path pub metadata: BTreeSet, } diff --git a/src/main.rs b/src/main.rs index 096a4b27..edb5e6ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,15 +12,15 @@ fn main() { } fn run() -> anyhow::Result<()> { - let args = Cli::from_args(); + let options = Cli::from_args(); - CLOG.set_log_level(args.log_level); + CLOG.set_log_level(options.log_level); - if args.quiet { + if options.quiet { CLOG.set_quiet(true); } - run_cli(args)?; + run_cli(options)?; Ok(()) }