feat: support @workdir directive to run commands in a specific directory#22
Merged
Conversation
…ctory Add @workdir directive at both file-level (frontmatter) and entry-level. Entry-level overrides file-level. Relative paths resolve relative to the .clitest file's directory. Fails with clear error if directory does not exist. - Parser recognizes @workdir in frontmatter and entry directives - Runner accepts dir parameter, sets cmd.Dir before execution - Works with EXIT NEVER, @defer, and [Prompts] entries - E2E tests covering: relative path, file-level, entry override, missing dir, defer inheritance Closes #21
- Combine param types in Run(command, dir string) - Use filepath.Clean before os.Stat to satisfy gosec G703
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
@workdir ./pathdirective that sets the working directory for a command's execution. Supported both as file-level (in frontmatter) and entry-level directive.Cascading:
cwd (default)←file-level @workdir←entry-level @workdirChanges
Workdir stringtoEntryDirectivesandFileDirectives@workdirin frontmatter and entry directivesdirparameter, setcmd.Dir.clitestfile's directory; validated at load timeTests
E2E tests covering: relative path, file-level, entry-level override, missing dir error, defer inherits file-level.
Closes #21