From 1cb38e94e9daf8c7402cb827e7c085eb8c8679fb Mon Sep 17 00:00:00 2001 From: Arshan Dabirsiaghi Date: Wed, 28 Feb 2024 17:06:47 -0500 Subject: [PATCH 1/2] Add wildcards to codemod selection arguments This PR adds a wildcarding ability to pass to `--codemod-include` (and exclude). --- cli.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cli.md b/cli.md index 28bf7b6..1449c85 100644 --- a/cli.md +++ b/cli.md @@ -33,13 +33,14 @@ The codemods must run in the given format: The `executable` could involve multiple command line tokens (e.g., `npm run` or `java -jar my-codemod.jar`) in order to invoke the executable. ## Implementation details -- Passing one of `--help`, `--list`, `--describe`, and `--version` will cause the given action to be run, then exit -- You can only run one of `--help`, `--list`, `--describe`, `--version`. Running multiple will cause an error and should show help like any other argument error +- Passing one of `--help`, `--list`, `--describe`, and `--version` will cause the given action to be run, then exit. +- You can only run one of `--help`, `--list`, `--describe`, `--version`. Running multiple will cause an error and should show help like any other argument error. - The only required field is ``. However, this field is not required if running either `--help`, `--list`, `--describe`, or `--version`. -- You cannot legally specify any argument more than one time -- If `--output` is given, it indicates the path where a codetf or diff file will be created (depending on the value of `--output-format`). Otherwise no output file is generated +- You cannot legally specify any argument more than one time. +- If `--output` is given, it indicates the path where a codetf or diff file will be created (depending on the value of `--output-format`). Otherwise no output file is generated. - All codemod rules are loaded by default unless `--codemode-include` specifies a list. `-codemode-exclude` works off all default codemods. -- Specifying a `--codemod-include`or `--codemod-exclude` that references a non-existent codemod will result in an error +- Specifying a `--codemod-include` or `--codemod-exclude` that references a non-existent codemod will result in an error +- You can specify a simple wildcard for `--codemod-include` and `--codemod-exclude` (e.g., `--codemod-include=acme:*`). If this pattern doesn't match any codemods, an error will result. - The `--path-include` and `--path-exclude` patterns are interpreted as relative to the given ``. In practice this means that the patterns should be joined with the `` when used internally and also when passed to external tools. - Codemodders are free to determine reasonable defaults for included and excluded paths. In general, codemodders should attempt to match only relevant source files and to ignore test directories and build artifacts by default. For example, codemodders will generally want to exclude `**/tests/**` by default. This will be interpreted relative to the given ``, which means that the effective pattern will be `/**/tests/**`. - For `--path-include` and `--path-exclude`, specific line numbers can be supplied. For instance, to include `src/Foo.java` but only allow changes found on line 11, you would pass `--path-include src/Foo.java:11`. From 039a069da47cad92683839f2720bdb33a1f072f1 Mon Sep 17 00:00:00 2001 From: Arshan Dabirsiaghi Date: Fri, 8 Mar 2024 13:58:38 -0500 Subject: [PATCH 2/2] PR feedback --- cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli.md b/cli.md index 1449c85..4f5968f 100644 --- a/cli.md +++ b/cli.md @@ -40,7 +40,7 @@ The `executable` could involve multiple command line tokens (e.g., `npm run` or - If `--output` is given, it indicates the path where a codetf or diff file will be created (depending on the value of `--output-format`). Otherwise no output file is generated. - All codemod rules are loaded by default unless `--codemode-include` specifies a list. `-codemode-exclude` works off all default codemods. - Specifying a `--codemod-include` or `--codemod-exclude` that references a non-existent codemod will result in an error -- You can specify a simple wildcard for `--codemod-include` and `--codemod-exclude` (e.g., `--codemod-include=acme:*`). If this pattern doesn't match any codemods, an error will result. +- You can specify a simple wildcard for `--codemod-include` and `--codemod-exclude` (e.g., `--codemod-include=acme:*`). If this pattern doesn't match any codemods, a warning will be issued. - The `--path-include` and `--path-exclude` patterns are interpreted as relative to the given ``. In practice this means that the patterns should be joined with the `` when used internally and also when passed to external tools. - Codemodders are free to determine reasonable defaults for included and excluded paths. In general, codemodders should attempt to match only relevant source files and to ignore test directories and build artifacts by default. For example, codemodders will generally want to exclude `**/tests/**` by default. This will be interpreted relative to the given ``, which means that the effective pattern will be `/**/tests/**`. - For `--path-include` and `--path-exclude`, specific line numbers can be supplied. For instance, to include `src/Foo.java` but only allow changes found on line 11, you would pass `--path-include src/Foo.java:11`.