Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff and check command line formatting #76

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/.idea
/.vscode
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,44 @@ Gherkin Utils is [available on Maven Central](https://central.sonatype.com/artif

## Command line

The command-line tool can be used to format `.feature` files or to translate `.feature` files
into `.feature.md` files.
Running Gherkin Utils from the command line provides formatting and conversion features.

The following example translates all `.feature` files to `.feature.md` files and then deletes the `.feature` files (see [Markdown with Gherkin](https://github.com/cucumber/common/blob/main/gherkin/MARKDOWN_WITH_GHERKIN.md)).
**Note**: Globs must be quoted to prevent the shell from expanding the globs.
```bash
> npx @cucumber/gherkin-utils format features
❌ 7 files failed to format
🥒 14 files left unchanged
🥒 25 files reformatted
```

```console
npx @cucumber/gherkin-utils format --move "features/**/*.feature" "features/**/*.feature.md"
To run Gherkin Utils as a formatter, try any of the following:

```bash
# Format `file.feature`
npx @cucumber/gherkin-utils format features/file.feature
# Format `one.feature` and `two.feature`
npx @cucumber/gherkin-utils format features/one.feature features/two.feature
# Format all feature files in `features/` (and any subdirectories)
npx @cucumber/gherkin-utils format features/
# Format all feature files ending with `_test.feature` in `features`
npx @cucumber/gherkin-utils format features/**/*_test.feature
# Check files that would be reformatted in `features/`
npx @cucumber/gherkin-utils format --check features/
# Check files that would be reformatted in `features/` and output the diff
npx @cucumber/gherkin-utils format --diff features/
```

To convert to [Markdown with Gherkin](https://github.com/cucumber/common/blob/main/gherkin/MARKDOWN_WITH_GHERKIN.md) or feature files while formatting, try the following:

```bash
# Format all feature files in `features/` (and any subdirectories) and convert to gherkin markdown
npx @cucumber/gherkin-utils format --to-syntax=markdown features/
# Format all feature files in `features/` (and any subdirectories) and convert to gherkin
npx @cucumber/gherkin-utils format --to-syntax=gherkin features/
```

For more details on usage, see the help menu.

```console
```bash
npx @cucumber/gherkin-utils --help
```

Expand Down Expand Up @@ -147,3 +172,7 @@ const scenarioNameFinder = new GherkinDocumentWalker({}, {
handleScenario: (scenario) => allScenarioNames.push(scenario.name),
})
```

## Feedback

If you discover a bug, or have a suggestion for a feature request, please submit an [issue](https://github.com/cucumber/gherkin-utils/issues).
Loading